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

Apl*_*lin 3 python dropbox

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

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

这是我的代码

def TakePicUpload(avg):
Run Code Online (Sandbox Code Playgroud)

Gre*_*reg 5

你得到一个file WriteConflictError

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

这被记录为:

有一个文件在路上。

因此,这仅意味着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 方法。