Beispiel #1
0
        public void Run()
        {
            string name   = "testpage5.html.zip"; // storage file name
            string folder = "/Html/TestData";     // storage folder name

            string filePath        = Path.Combine(CommonSettings.LocalDataFolder, name);
            string storageFilePath = Path.Combine(folder, name).Replace('\\', '/');

            if (File.Exists(filePath))
            {
                SdkBaseRunner.UploadToStorage(storageFilePath, filePath);
            }
            else
            {
                throw new Exception(string.Format("Error: file {0} not found.", filePath));
            }

            IDocumentApi docApi = new HtmlApi(CommonSettings.ClientId, CommonSettings.ClientSecret, CommonSettings.BasePath);
            // call SDK method that gets a zip archive with all HTML document images
            var response = docApi.GetDocumentImages(name, null, folder);

            if (response != null && response.ContentStream != null && response.Status == "OK")
            {
                Stream stream  = response.ContentStream;
                string outFile = $"{Path.GetFileNameWithoutExtension(response.FileName)}_images.zip";
                string outPath = Path.Combine(CommonSettings.OutDirectory, outFile);
                using (FileStream fstr = new FileStream(outPath, FileMode.Create, FileAccess.Write))
                {
                    stream.Position = 0;
                    stream.CopyTo(fstr);
                    fstr.Flush();
                    Console.WriteLine(string.Format("\nResult file downloaded to: {0}", outPath));
                }
            }
        }
Beispiel #2
0
        public void Test_GetDocumentImages()
        {
            string name   = "testpage5.html.zip";
            string folder = StorageTestDataPath;

            var response = HtmlApi.GetDocumentImages(name, null, folder);

            checkGetMethodResponse(response, "Document", "_images");
        }