public IHttpActionResult GetFile(Guid guid) { HttpContext.Current.Response.Buffer = true; //Get file name and soachapterid from db, create correct FilePath including companyid var file = UploadService.GetFile(guid); if (file == null) { return(null); } return(new FileActionResult(file.FileName, Path.Combine(BaseFilePath, file.Template ? "000" : CompanyId.ToString(), file.SoaChapterId.ToString()))); }
public IHttpActionResult Delete(Guid id) { var file = UploadService.GetFile(id); if (file == null) { return(BadRequest("File not found")); } var path = Path.Combine(BaseFilePath, file.Template ? "000" : CompanyId.ToString(), file.SoaChapterId.ToString(), file.FileName); if (File.Exists(path)) { File.Delete(path); } UploadService.DeleteFile(file); return(Ok()); }