public async Task <IActionResult> Upload([FromForm] IFormFile file) { var user = await _currentUserInfo.GetCurrentUser(); if (user == null) { return(Unauthorized()); } if (file.ContentType != "image/jpeg") { return(BadRequest()); } await using var stream = file.OpenReadStream(); await _pictureStorage.PostPicture(stream, user); return(CreatedAtAction("GetPicture", "")); }
public async Task <IActionResult> PostImage(int id, [FromForm] IFormFile file) { if (!IPictureStorageInfo.IsSupported(file?.ContentType)) { return(new UnsupportedMediaTypeResult()); } var entry = await _context.EquipmentDetails.FindAsync(id); if (entry == null) { return(NotFound()); } await using var stream = file !.OpenReadStream(); await _pictureStorage.PostPicture(stream, entry); return(Ok()); }