Last changes before exam
This commit is contained in:
@@ -7,12 +7,12 @@ public class StorageService(IAmazonS3 amazonS3, IConfiguration config)
|
||||
{
|
||||
private readonly string _bucket = config["RustFs:BucketName"]!;
|
||||
private readonly string _url = config["RustFs:ServiceUrl"]!;
|
||||
|
||||
|
||||
public async Task<string> UploadFile(IFormFile file, string type, CancellationToken ct)
|
||||
{
|
||||
if (file.Length == 0) throw new Exception("Fichier vide");
|
||||
|
||||
string key = $"settings/{type}";
|
||||
|
||||
string key = $"settings/{type}/{Guid.NewGuid()}";
|
||||
|
||||
using MemoryStream memoryStream = new();
|
||||
await file.CopyToAsync(memoryStream, ct);
|
||||
@@ -25,7 +25,7 @@ public class StorageService(IAmazonS3 amazonS3, IConfiguration config)
|
||||
InputStream = memoryStream,
|
||||
Key = key,
|
||||
};
|
||||
|
||||
|
||||
await amazonS3.PutObjectAsync(uploadRequest, ct);
|
||||
return key;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user