public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "test_uploadfile.docx"; String format = "pdf"; String storage = ""; String folder = ""; String outPath = ""; try { // Upload file to aspose cloud storage storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to convert document to images ResponseMessage apiResponse = wordsApi.GetDocumentWithFormat(fileName, format, storage, folder, outPath); if (apiResponse != null && apiResponse.Status.Equals("OK")) { System.Diagnostics.Debug.WriteLine("response:" + apiResponse.ResponseStream); System.IO.File.WriteAllBytes(Common.GetDataDir() + "WordFormatConverterExampleTest.pdf", apiResponse.ResponseStream); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public void TestGetDocumentFormatUsingStorage() { var localName = "test_multi_pages.docx"; var remoteName = "TestGetDocumentFormatUsingStorage.docx"; var fullName = Path.Combine(this.dataFolder, remoteName); var format = "text"; var storage = "AWSStorageS3"; // TODO to run this test please put your AppKey and AppSid for another storage // var anotherStorageApi = new StorageApi(StorageAppKey, StorageAppSID, BaseProductUri); // anotherStorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir(BaseTestContext.CommonFolder) + localName)); var anotherWordApi = new WordsApi(new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.AppKey, AppSid = this.AppSid }); var request = new GetDocumentWithFormatRequest(remoteName, format, this.dataFolder, storage); var result = anotherWordApi.GetDocumentWithFormat(request); Assert.IsTrue(result.Length > 0, "Conversion has failed"); }