Skip to content

Instantly share code, notes, and snippets.

@sle-c
Created July 18, 2016 04:29
Show Gist options
  • Save sle-c/67e7757335161f5906f997a38aa9799a to your computer and use it in GitHub Desktop.
Save sle-c/67e7757335161f5906f997a38aa9799a to your computer and use it in GitHub Desktop.
Babl module dropbox upload method
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