public void Run()
        {
            string name = "testpage5.html.zip";   // storage file name
            string folder = "HtmlTemp"; // storage folder name

            string filePath = Path.Combine(CommonSettings.DataFolder, name);
            if (File.Exists(filePath))
            {
                SdkBaseRunner.uploadToStorage(name, CommonSettings.DataFolder);
            }
            else
                throw new Exception(string.Format("Error: file {0} not found.", filePath));

            IDocumentApi docApi = new DocumentApi(CommonSettings.AppKey, CommonSettings.AppSID, CommonSettings.BasePath);
            // call SDK method that gets a zip archive with all HTML document images
            Stream stream = docApi.GetDocumentImages(name, null, folder);
            if (stream != null && typeof(FileStream) == stream.GetType())
            {
                string outFile = $"{Path.GetFileNameWithoutExtension(name)}_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));
                }
            }

        }
        public void Run()
        {
            var name  = "testpage3_embcss.html";
            var xPath = "//ol/li";
            // Upload source file to cloud storage (default is AmazonS3)
            var srcPath = Path.Combine(CommonSettings.DataFolder, name);

            if (File.Exists(srcPath))
            {
                SdkBaseRunner.uploadToStorage(name, CommonSettings.DataFolder);
            }
            else
            {
                throw new Exception(string.Format("Error: file {0} not found.", srcPath));
            }

            IDocumentApi docApi = new DocumentApi(CommonSettings.AppKey, CommonSettings.AppSID, CommonSettings.BasePath);
            // call the SDK method that returns a query result in the response stream.
            Stream stream = docApi.GetDocumentFragmentByXPath(name, xPath, "json", null, null);

            if (stream != null && typeof(FileStream) == stream.GetType())
            {
                string outFile = $"{Path.GetFileNameWithoutExtension(name)}_fragments.json";
                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));
                }
            }
        }
        public void Run()
        {
            string name    = "testpage1.html";
            string folder  = null;
            string storage = null;

            string srcPath = Path.Combine(CommonSettings.DataFolder, name);

            if (File.Exists(srcPath))
            {
                var storagePath = !string.IsNullOrEmpty(folder)
                    ? string.Format("{0}/{1}", folder, name) : name;

                bool uploaded = SdkBaseRunner.uploadToStorage(storagePath, CommonSettings.DataFolder);

                if (uploaded)
                {
                    TranslationApi transApi = new TranslationApi(CommonSettings.AppKey, CommonSettings.AppSID, CommonSettings.BasePath);
                    Stream         stream   = transApi.GetTranslateDocument(name, SrcLang, ResLang, folder, storage);

                    if (stream != null && stream.GetType() == typeof(FileStream))
                    {
                        string outName = ((FileStream)stream).Name;
                        string outPath = Path.Combine(CommonSettings.OutDirectory, Path.GetFileName(outName));
                        using (FileStream fstr = new FileStream(outPath, FileMode.Create, FileAccess.Write))
                        {
                            stream.CopyTo(fstr);
                            fstr.Flush();
                            Console.WriteLine(string.Format("File '{0}' downloaded to: {1}", Path.GetFileName(outName), outPath));
                        }
                    }
                    stream.Close();
                    stream.Dispose();
                }
            }
            else
            {
                throw new FileNotFoundException("File not found in the Data folder", name);
            }
        }