Created
July 18, 2016 04:29
-
-
Save sle-c/67e7757335161f5906f997a38aa9799a to your computer and use it in GitHub Desktop.
Babl module dropbox upload method
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
def upload(dbx, data, path, overwrite=False): | |
"""Upload a file. | |
Return the request response, or None in case of error. | |
""" | |
mode = (dropbox.files.WriteMode.overwrite | |
if overwrite | |
else dropbox.files.WriteMode.add) | |
try: | |
res = dbx.files_upload(data, path, mode) | |
except dropbox.exceptions.ApiError as err: | |
print('*** API error', err) | |
return None | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment