41 lines
830 B
C#
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;
|
|
}
|
|
}
|
|
|
|
|