초기커밋
This commit is contained in:
40
UGQApiServer/Storage/LocalStorageService.cs
Normal file
40
UGQApiServer/Storage/LocalStorageService.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user