我正在尝试使用python dropbox api中的files_upload方法将本地csv文件上传到dropbox帐户。这会引发内部服务器错误。以前,它工作正常.Below是我的代码。
import dropbox
from dropbox.files import WriteMode
from dropbox.exceptions import ApiError, AuthError
d = dropbox.Dropbox('xxxxxxxxx')
with open(pricing_plan_unit_no_data_csv_path, 'rb') as f:
# We use WriteMode=overwrite to make sure that the settings in the file
# are changed on upload
BACKUPPATH = '/IH_Permit_and_Title_processing/Title_input_for_KNIME/' + lastmonth.strftime("%m_%Y") + '/' + 'plan_unit_'+lastmonth.strftime("%m_%Y")+'_nodata.csv'
print("Uploading " + pricing_plan_unit_no_data_csv_path + " to Dropbox as " + BACKUPPATH + "...")
try:
d.files_upload(f.read(), BACKUPPATH, mode=WriteMode('overwrite'))
f.close()
except ApiError as err:
# This checks for the specific error where a user doesn't have
# enough Dropbox space quota to upload this file
if (err.error.is_path() and err.error.get_path().error.is_insufficient_space()):
sys.exit("ERROR: Cannot back up; insufficient space.")
elif err.user_message_text:
print(err.user_message_text)
sys.exit()
else:
print(err)
sys.exit()
以下是错误
File "C:/Users/Kcs-Lpt-00020/PycharmProjects/IH_Permit_and_Tiltle_Processing/pricinginformationdropbox.py", line 301, in
d.files_upload(f.read(), BACKUPPATH, mode=WriteMode('overwrite'))
File "C:\Python34\lib\site-packages\dropbox\base.py", line 1252, in files_upload
f,
File "C:\Python34\lib\site-packages\dropbox\dropbox.py", line 249, in request
timeout=timeout)
File "C:\Python34\lib\site-packages\dropbox\dropbox.py", line 341, in request_json_string_with_retry
timeout=timeout)
File "C:\Python34\lib\site-packages\dropbox\dropbox.py", line 430, in request_json_string
raise InternalServerError(request_id, r.status_code, r.text)
dropbox.exceptions.InternalServerError: InternalServerError('a12a84f64e3ae72a9b09c1d6831648f0', 500, '')