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