public async Task <ActionResult <FileStorageDto> > Save(IFormFile fileToStore) { FileStorage currentWorkingObject = new FileStorage(); try { currentWorkingObject.FileData = fileToStore.OpenReadStream(); currentWorkingObject.ContentType = fileToStore.ContentType; currentWorkingObject.FileName = fileToStore.FileName; currentWorkingObject.SizeKB = fileToStore.Length / 1024; await _fileStorageManager.SaveAsync(currentWorkingObject); } catch (Exception apiControllerError) { _applicationLogTools.LogError(apiControllerError, new Dictionary <string, dynamic> { { "ClassName", "WebApi.FileStorageController" } }); if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT").Equals("Development", StringComparison.InvariantCultureIgnoreCase)) { return(base.StatusCode(500, apiControllerError)); } else { return(base.StatusCode(500)); } } return(_mapper.Map <FileStorage, FileStorageDto>(currentWorkingObject)); }