public async Task <FileInfoDto> UpdateAsync(Guid id, [FromForm] UpdateFileActionInput input) { if (input.File == null) { throw new NoUploadedFileException(); } await using var memoryStream = new MemoryStream(); await input.File.CopyToAsync(memoryStream); return(await _service.UpdateAsync(id, new UpdateFileInput { FileName = input.FileName, MimeType = input.File.ContentType, Content = memoryStream.ToArray() })); }
public virtual async Task <IActionResult> OnPostAsync() { var dto = await _service.GetAsync(Id); if (Path.GetExtension(UploadedFile.FileName) != Path.GetExtension(dto.FileName)) { throw new ReUploadWithDifferentExtensionException(); } var updateFileDto = new UpdateFileInput { FileName = dto.FileName, MimeType = UploadedFile.ContentType, Content = await UploadedFile.GetAllBytesAsync() }; await _service.UpdateAsync(Id, updateFileDto); return(NoContent()); }