Change some things
This commit is contained in:
@@ -74,11 +74,13 @@
|
||||
|
||||
public async Task UploadRecipeMediaAsync(Guid recipeId, IFormFile mediaFile)
|
||||
{
|
||||
if (mediaFile == null)
|
||||
if (mediaFile == null || mediaFile.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(mediaFile));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var recipe = await _recipeRepository.GetRecipeAsync(recipeId);
|
||||
|
||||
var isImage = mediaFile.ContentType.StartsWith("image/");
|
||||
@@ -114,6 +116,11 @@
|
||||
_context.MediaFiles.Add(newMedia);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidOperationException("An error occurred while uploading the media file.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RemoveExistingMediaAsync(Recipe recipe, string mediaTypePrefix)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user