public async Task <IActionResult> Create([FromForm] string request, IFormFile file) { try { if (file == null || file.Length == 0) { return(BadRequest()); } var userKey = _contextAccessor.UserKeyFromContext(); //var contentType = file.ContentType; var createFileRequest = JsonSerializer.Deserialize <CreateFileRequest>(request, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); var storageService = _storageServiceProvider.Service(createFileRequest.StorageService); createFileRequest.StorageService = storageService.Name; // fill in the StorageService field in the case that null was passed (for Default) IFileInformation versionInfo = null; using var stream = file.OpenReadStream(); versionInfo = await storageService.StoreFile(stream); var newFile = await _hiarcDatabase.CreateFile(createFileRequest, userKey, versionInfo.StorageIdentifier); var uri = $"{_hiarcSettings.BaseUri}/files/{newFile.Key}"; return(Created(uri, newFile)); } catch (Exception ex) { return(BuildErrorResponse(ex, _logger)); } }