Aplin
Aplin

Reputation: 115

Dropbox API error when uploading image (Python)

I am currently doing a motion detection program. I have already managed to capture images when motion is detected. I want the photos to be uploaded to Dropbox when captured. It works fine for the first few images but stops working after awhile. It displays the following error

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

This is my code

def TakePicUpload(avg):

Upvotes: 3

Views: 3388

Answers (1)

Greg
Greg

Reputation: 16940

You're getting a file WriteConflictError:

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

That's documented as:

There’s a file in the way.

So, that just means there's already at the path (savetolocation in your case) where you're trying to upload.

You can either remove that file if you don't want it, or specify a different write mode when calling files_upload:

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

More specifically you can add mode=dropbox.files.WriteMode.overwrite as a parameter to files_upload method.

Upvotes: 7

Related Questions