public void Test_GetImportMarkdownToHtml_StorageFileToResponse_1() { var name = "testpage1.md"; string folder = StorageTestDataPath; string storage = null; var response = HtmlApi.GetImportMarkdownToHtml(name, folder, storage); checkGetMethodResponse(response, "Conversion", "_md_to_html"); }
public void Run() { // setup HTML document name var name = "testpage1.md"; // setup local document path var srcPath = Path.Combine(CommonSettings.LocalDataFolder, name); // setup storage folder where the source document should be present string folder = CommonSettings.StorageDataFolder; // setup storage name (null for default storage) string storage = null; string storagePath = (folder == null) ? name : Path.Combine(folder, name).Replace('\\', '/'); string outFile = $"{name}_get_to_html_{DateTime.Now.ToString("yyyyMMdd_hhmmss")}.html"; if (File.Exists(srcPath)) { SdkBaseRunner.UploadToStorage(storagePath, srcPath); } else { throw new Exception(string.Format("Error: file {0} not found.", srcPath)); } IImportApi impApi = new HtmlApi(CommonSettings.ClientId, CommonSettings.ClientSecret, CommonSettings.BasePath, CommonSettings.AuthPath); StreamResponse response = impApi.GetImportMarkdownToHtml(name, folder, storage); if (response != null && response.ContentStream != null && response.Status == "OK") { var respFileName = response.FileName; Stream outStream = response.ContentStream; string outPath = Path.Combine(CommonSettings.OutDirectory, respFileName ?? outFile); using (FileStream fstr = new FileStream(outPath, FileMode.Create, FileAccess.Write)) { outStream.Position = 0; outStream.CopyTo(fstr); fstr.Flush(); Console.WriteLine(string.Format("\nResult file downloaded to: {0}", outPath)); } } }