//TODO Clean word document private void CleanDocument(string fileId) { DocumentType docType; switch (Path.GetExtension(fileId).ToUpper()) { case ".DOCX": docType = DocumentType.Words; break; case ".DOC": docType = DocumentType.Words; break; case ".PPTX": docType = DocumentType.Slides; break; case ".PPT": docType = DocumentType.Slides; break; case ".XLSX": docType = DocumentType.Cells; break; case ".XLS": docType = DocumentType.Cells; break; default: docType = DocumentType.Pdf; break; } using (Stream inputDoc = _annotator.GetFile(fileId).Stream) { SaveCleanDocument(inputDoc, fileId, docType); } }
public static Stream GetFile(GetFileParameters parameters) { string displayName = string.IsNullOrEmpty(parameters.DisplayName) ? Path.GetFileName(parameters.Path) : Uri.EscapeDataString(parameters.DisplayName); Stream fileStream = annotator.GetFile(parameters.Path).Stream; //jquery.fileDownload uses this cookie to determine that a file download has completed successfully HttpContext.Current.Response.SetCookie(new HttpCookie("jqueryFileDownloadJSForGD", "true") { Path = "/" }); return(fileStream); }
public ActionResult GetFile(GetFileParameters parameters) { string displayName = string.IsNullOrEmpty(parameters.DisplayName) ? Path.GetFileName(parameters.Path) : Uri.EscapeDataString(parameters.DisplayName); Stream fileStream = annotator.GetFile(parameters.Path).Stream; //jquery.fileDownload uses this cookie to determine that a file download has completed successfully Response.SetCookie(new HttpCookie("jqueryFileDownloadJSForGD", "true") { Path = "/" }); return(File(GetBytes(fileStream), "application/octet-stream", displayName)); }