Skip to content

Instantly share code, notes, and snippets.

@quamis
Created April 23, 2014 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quamis/11217146 to your computer and use it in GitHub Desktop.
Save quamis/11217146 to your computer and use it in GitHub Desktop.
import os, sys
lib_path = os.path.abspath('python-cloudconvert')
sys.path.append(lib_path)
import CloudConvert
apikey = "xxxxxxxxxx"
process = CloudConvert.ConversionProcess(apikey)
# This should autodetect file extension. if not, you can
# always set process.fromformat and .toformat to the correct
# values
process.init("../samples/abc.rtf", "abc.epub")
process.fromformat = "rtf"
process.toformat = "epub"
# Will block until file is done processing. You can set
# the interval between checks.
process.wait_for_completion(check_interval=1)
# Returns a file-like obj to download the processed file
download = process.download()
with open("abc.epub", "wb") as f: # Important to set mode to wb
f.write(download.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment