|
|
@ -42,18 +42,22 @@ namespace CoviDok.Controllers |
|
|
|
public async Task<ActionResult<GenericResponse>> OnPostImage(ImagePost post) |
|
|
|
{ |
|
|
|
GenericResponse response = new GenericResponse(); |
|
|
|
Session s = await Handler.GetSession(post.SessionId); |
|
|
|
if (s == null) |
|
|
|
try |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(post.SessionId); |
|
|
|
Console.WriteLine("ImagesController:OnPostImage - Incoming request, ID: " + post.SessionId + ", payload: " + post.File.Length); |
|
|
|
string id = Cuid.Generate(); |
|
|
|
StorageResult Result = await MinioHandler.UploadImage(BucketName, MakeStream(post.File), post.File.Length, id); |
|
|
|
Console.WriteLine("ImagesController:OnPostImage - Request successful, uploaded " + id); |
|
|
|
if (!Result.Success) response.Status = Status.Error; |
|
|
|
response.Body["reason"] = Result.Data; |
|
|
|
return response; |
|
|
|
} |
|
|
|
catch (UnauthorizedAccessException) { |
|
|
|
response.Status = Status.Error; |
|
|
|
response.Body["reason"] = "unauthorized"; |
|
|
|
return response; |
|
|
|
} |
|
|
|
StorageResult Result = await MinioHandler.UploadImage(BucketName, MakeStream(post.File), post.File.Length, Cuid.Generate()); |
|
|
|
if (!Result.Success) response.Status = Status.Error; |
|
|
|
response.Body["reason"] = Result.Data; |
|
|
|
|
|
|
|
return response; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("Download")] |
|
|
|