We are using python .
Our code for instantiating , uploading, and downloading -:
@classmethod
def GetConfig(cls):
configuration = groupdocs_conversion_cloud.Configuration(cls.client_id, cls.client_secret)
configuration.api_base_url = "https://api.groupdocs.cloud"
return configuration
@classmethod
def UploadSampleFiles(cls,foldername,filename):
# api initialization
storageApi = groupdocs_conversion_cloud.StorageApi.from_config(cls.GetConfig())
fileApi = groupdocs_conversion_cloud.FileApi.from_config(cls.GetConfig())
# upload sample files
print('upoadin filee ',filename)
destFile = filename.replace(foldername+"\\", "", 1)
fileExistsResponse = storageApi.object_exists(groupdocs_conversion_cloud.ObjectExistsRequest(destFile))
if not fileExistsResponse.exists:
fileApi.upload_file(groupdocs_conversion_cloud.UploadFileRequest(destFile, filename))
print("Uploaded file: "+ destFile)
@classmethod
def DownloadFiles(cls,dir,html_file_name,filepath):
# Create instance of the API
# api initialization
storageApi = groupdocs_conversion_cloud.StorageApi.from_config(cls.GetConfig())
fileApi = groupdocs_conversion_cloud.FileApi.from_config(cls.GetConfig())
try:
request = groupdocs_conversion_cloud.DownloadFileRequest(filepath, "demo")
response = fileApi.download_file(request)
print("Expected response type is Stream: " , type(response)," ",type(request)," ",response," ",request)
# #filename.write_bytes(response.content)
print(os.path.join(dir,html_file_name))
copyfile(str(response), os.path.join(dir,html_file_name))
except groupdocs_conversion_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
For conversion-:
class ConvertToHtml:
@classmethod
def Run(cls,filepath):
# Create necessary API instances
apiInstance = groupdocs_conversion_cloud.ConvertApi.from_config(Common.GetConfig())
# Prepare convert settings
settings = groupdocs_conversion_cloud.ConvertSettings()
settings.file_path = filepath
settings.format = "html"
convertOptions = groupdocs_conversion_cloud.HtmlConvertOptions()
settings.convert_options = convertOptions
settings.output_path = 'demo'
# Convert
result = apiInstance.convert_document(groupdocs_conversion_cloud.ConvertDocumentRequest(settings))
print("Document converted: " + result[0].url)