Created
April 23, 2014 14:22
-
-
Save quamis/11217146 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 characters
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