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

petal's avatar
petal
Explorer | Level 4
4 years ago

some questions about write mode

Hi:

    It seems that dropbox handle files when there is a conflict like this: If one file in dropbox is being updated by multiple devices, some conflicting copies will be created, and users should merge these confilting files manully. Whether  I set write mode to add, overwrite or update has no influence about this. The conficting copy will be created anyway. 

    Now, I want to integrate dropbox into my own app by Java SDK for API v2. It seems the way dropbox app take a little inconvenient. So I wonder if there any other API for developers to handle this case?

    Another question is, how should I log out a dropbox account by API? And can I have a callback after successfully logging out to, for example, notify my own server?

    Thanks!

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    When uploading files to Dropbox via the API, there are a number of different options you can use to control how overwriting, renaming, and conflicts work. For example, with the Java SDK, on the UploadBuilder class, refer to the documentation for UploadBuilder.withAutorenameUploadBuilder.withStrictConflict, and UploadBuilder.withMode. Also, be sure to read the documentation for WriteMode itself, as it has some more information on how the different write modes work. If something isn't working as documented, please share the steps and code to reproduce the issue so we can look into it.

     

    Regarding logging out, there are actually a few different things this may refer to. I recommend reading this post for information on the different options. The Dropbox API doesn't offer a way to be notified when a user disconnects your app, but you can perform whatever calls you need from your app's own code of course.

    • petal's avatar
      petal
      Explorer | Level 4

      Thanks, I have read the WriteMode link you give, and notice the description in the document.

      The description about "ADD" is: Do not overwrite an existing file if there is a conflict. The autorename strategy is to append a number to the file name. For example, "document.txt" might become "document (2).txt".

      And description about "OVERWRITE" is: Always overwrite the existing file. The autorename strategy is the same as it is for ADD.

      But I still don't konw the difference between these two options. Since both option will create a new file like "document (2).txt", how should I understand the words "Always overwrite the existing file"? If I set write mode to overwrite, will every update from multiple devices be added to the end of "document.txt", and at the same time create "document (2).txt" for every update. And if in add mode, app will only create "document (2).txt", and don't add update to "document.txt" ? Did I understand in the right way? I don't have enough devices to try this, so I sincerely hope you can help me figure this out.

      Thanks!

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        If you use "overwrite", an existing file will be replaced by the new data. If you use "add", an existing file will not be replaced by the new data.

         

        You don't actually need multiple devices to test this. You can just run multiple API calls from one place. I recommend using the API v2 Explorer to test this out. (You can even open it in multiple windows/tabs if you want.)

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,910 PostsLatest Activity: 3 days ago
333 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!