/// <summary> /// Converts binary to blob pointer /// </summary> /// <param name="category">The file category.</param> /// <param name="data">The data.</param> /// <param name="name">The name.</param> /// <returns>Blob Pointer</returns> public static string ConvertToFile(string category, string name, byte[] data) { if (data == null) { return null; } using (Stream stream = new MemoryStream(data)) { // convert doc, xls -> docx, xlsx Stream streamToSave = new MemoryStream(); if (FileTypeDetector.IsDoc(data)) { Aspose.Words.Document doc = new Aspose.Words.Document(stream); doc.RemoveMacros(); doc.Save(streamToSave, Aspose.Words.SaveFormat.Docx); } else if (FileTypeDetector.IsXls(data)) { Aspose.Cells.Workbook xls = new Aspose.Cells.Workbook(stream); xls.RemoveMacro(); xls.Save(streamToSave, Aspose.Cells.SaveFormat.Xlsx); } else { streamToSave = stream; } // save to file streamToSave.Position = 0; string result = BlobStoreProvider.Instance.PutBlob(category, name, streamToSave); return result; } }
/// <summary> /// Converts binary to blob pointer /// </summary> /// <param name="category">The file category.</param> /// <param name="data">The data.</param> /// <param name="name">The name.</param> /// <returns>Blob Pointer</returns> public static string ConvertToFile(string category, string name, byte[] data) { if (data == null) { return(null); } using (Stream stream = new MemoryStream(data)) { // convert doc, xls -> docx, xlsx Stream streamToSave = new MemoryStream(); if (FileTypeDetector.IsDoc(data)) { Aspose.Words.Document doc = new Aspose.Words.Document(stream); doc.RemoveMacros(); doc.Save(streamToSave, Aspose.Words.SaveFormat.Docx); } else if (FileTypeDetector.IsXls(data)) { Aspose.Cells.Workbook xls = new Aspose.Cells.Workbook(stream); xls.RemoveMacro(); xls.Save(streamToSave, Aspose.Cells.SaveFormat.Xlsx); } else { streamToSave = stream; } // save to file streamToSave.Position = 0; string result = BlobStoreProvider.Instance.PutBlob(category, name, streamToSave); return(result); } }