Dropbox API 上传图片时出错 (Python)

Dropbox API error when uploading image (Python)

我目前正在做一个运动检测程序。我已经设法在检测到运动时捕获图像。我希望照片在拍摄时上传到 Dropbox。它适用于前几张图片,但过一会儿就停止工作了。它显示以下错误

ApiError: ApiError('', UploadError(u'path', UploadWriteFailed(reason=WriteError(u'conflict', WriteConflictError(u'file', None)), upload_session_id=u'')))

这是我的代码

def TakePicUpload(avg):

您将获得 file WriteConflictError:

https://dropbox-sdk-python.readthedocs.io/en/latest/api/files.html?highlight=writeconflicterror#dropbox.files.WriteConflictError

记录为:

There’s a file in the way.

所以,这只是意味着已经存在您尝试上传的路径(savetolocation 在您的情况下)。

如果不需要该文件,您可以将其删除,或者在调用 files_upload:

时指定不同的写入模式

https://dropbox-sdk-python.readthedocs.io/en/latest/api/dropbox.html?highlight=files_upload#dropbox.dropbox.Dropbox.files_upload

更具体地说,您可以将 mode=dropbox.files.WriteMode.overwrite 作为参数添加到 files_upload 方法。