Files
caliverse_server/UGQApiServer/Storage/LocalStorageService.cs
2025-05-01 07:20:41 +09:00

41 lines
830 B
C#

namespace UGQApiServer.Storage;
public class LocalStorageService : IStorageService
{
public LocalStorageService()
{
}
public string fileUrl(string filename)
{
return filename;
}
public async Task<bool> uploadFile(string filename, IFormFile file)
{
await Task.CompletedTask;
string path = Path.Combine(Directory.GetCurrentDirectory(), "files");
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
using (var stream = new FileStream(Path.Combine(path, filename), FileMode.Create))
{
file.CopyTo(stream);
}
return true;
}
public async Task<bool> deleteFile(string filename)
{
await Task.CompletedTask;
System.IO.File.Delete(filename);
return true;
}
}