Does Dropbox API provide check-and-swap type of operation or any other way to ensure that when I'm updating a file - I'm updating the version of the file that I specified and not overwriting someone else's changes in a race-condition?
For example some APIs support If-Match
header for that purpose.
Yes, when uploading files via the Dropbox API, the way to do this is to use the update
WriteMode
, and supply the rev
value of the version of the file you want to write on top of:
https://www.dropbox.com/developers/documentation/http/documentation#files-upload
If it doesn't match, the API will return a conflict instead of overwriting someone else's changes.
You can get the rev
value for the version you're updating from wherever you received that version of the file via the API, e.g., from the download endpoint:
https://www.dropbox.com/developers/documentation/http/documentation#files-download