public async Task <IActionResult> SaveUploadedFile() { bool isSavedSuccessfully = true; string fName = ""; try { foreach (IFormFile file in Request.Form.Files) { //Save file content goes here fName = file.FileName; CreatePictureDTO dto = new CreatePictureDTO(); dto.Description = fName; using (Stream fs = file.OpenReadStream()) { dto.Picture = file.OpenReadStream(); } await _profileService.AddPicture(dto);; } } catch (Exception ex) { _logger.LogError($"Error trying to process {nameof(SaveUploadedFile)} method. Exception --> {ex.Message}"); isSavedSuccessfully = false; } if (isSavedSuccessfully) { return(Ok(new { Message = fName })); } else { return(Ok(new { Message = "Error in saving file" })); } }