You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

latimba's avatar
latimba
Explorer | Level 3
5 years ago

Handling of local and remote rev differences

Hello, I would like to ask for some confirmations and clarifications on syncing dropbox files with API v2. I think I have uploading, downloading and listening for changes mostly figured out. My pro...
  • Greg-DB's avatar
    5 years ago

    1. Yes, you're definitely on the right track here, and your description sounds right. There are a few extra pieces of functionality that you may want to be aware of too. First, while "rev" identifies a particular revision of a file, the Dropbox API also offers a "content hash" which is directly indicative of the actual contents of the file. You can find more information on that here.

    There's also some other options around using the "rev" that I'll cover below as they address your other questions.

    2. If you're only interested in changes going forward, you can use /2/files/list_folder/get_latest_cursor and /2/files/list_folder/continue like you said. Alternatively, if you want to start from a complete representation of the state of the account (or whatever folder you're interested in) though, you can instead start with /2/files/list_folder followed by /2/files/list_folder/continue as necessary to list everything.

    Either way, you can then keep track of further changes by calling /2/files/list_folder/continue with the last returned cursor. Be sure to carefully read the /2/files/list_folder documentation for information on how to correctly process the returned entries.

    (And for reference, those are links to the documentation for the HTTPS endpoints themselves, but we recommend using one of the official SDKs if possible, if you aren't already. Those have corresponding native methods for the HTTPS endpoints.)

    Regardless, you're correct that you can check the current "rev" to see if the file has since changed, but that there is also inherently a race condition possible between when you last checked the metadata and when you actually perform an upload. For that reason, the "update" mode is generally the best and safest mode to use when continually updating an existing file. You can configure what Dropbox does when a conflict occurs though, as in your question 3.

    3. Yes, when using the "update" write mode, if you set "autorename:false" (or omit the parameter entirely, as that's the default), Dropbox will automatically fail the upload request and return an error instead of committing a conflicted copy.

    Hope this helps! 

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API

Make connections with other developers

795 PostsLatest Activity: 9 days ago
193 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!