Created
September 14, 2023 05:07
Revisions
-
groupdocs-cloud-gists created this gist
Sep 14, 2023 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ # Load TXT file into editable state fileInfo = groupdocs_editor_cloud.FileInfo("Text/document.txt") loadOptions = groupdocs_editor_cloud.TextLoadOptions() loadOptions.file_info = fileInfo loadOptions.output_path = "output" loadResult = editApi.load(groupdocs_editor_cloud.LoadRequest(loadOptions)) # Download html document htmlFile = fileApi.download_file(groupdocs_editor_cloud.DownloadFileRequest(loadResult.html_path)) html = "" with open(htmlFile, 'r') as file: html = file.read() # Edit something... html = html.replace("Page Text", "New Text") # Upload html back to storage with open(htmlFile, 'w') as file: file.write(html) fileApi.upload_file(groupdocs_editor_cloud.UploadFileRequest(loadResult.html_path, htmlFile)) # Save html back to txt saveOptions = groupdocs_editor_cloud.TextSaveOptions() saveOptions.file_info = fileInfo saveOptions.output_path = "output/edited.txt" saveOptions.html_path = loadResult.html_path saveOptions.resources_path = loadResult.resources_path saveResult = editApi.save(groupdocs_editor_cloud.SaveRequest(saveOptions)) This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ import groupdocs_editor_cloud # Get app_sid & app_key from https://dashboard.groupdocs.cloud after free registration. app_sid = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" app_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # Get File API configurations. configuration = groupdocs_editor_cloud.Configuration(app_sid, app_key) configuration.api_base_url = "https://api.groupdocs.cloud" storage_name = "LocalStorage" This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ # Create an instance of the file API file_api = groupdocs_editor_cloud.FileApi.from_config(configuration) # Call upload file request request = groupdocs_editor_cloud.UploadFileRequest("images\source.jpg", "H:\\groupdocs-cloud-data\\source.jpg", storage_name) # Upload file to the cloud response = file_api.upload_file(request) print(response.uploaded)