public async Task <IActionResult> Upload(IFormFile file) { using (var ms = new MemoryStream()) { try { await file.CopyToAsync(ms); ms.Position = 0; var exists = await _checkSumManager.FileExists(ms); if (exists) { return(BadRequest("File already exists")); } ms.Position = 0; await _checkSumManager.AddFile(ms); ms.Position = 0; var filename = await _fileIO.Write(ms, file.FileName); var url = $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}/files/{filename}"; return(Ok(url)); } catch (System.Exception) { return(BadRequest()); } } }
public void Save() { _fileIO.Write(typeof(T), Settings, _filePath); }