We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here. 

Forum Discussion

chrismcqueen's avatar
chrismcqueen
Explorer | Level 4
5 years ago

What String to use in writemode update

My goal is to use SwiftyDropbox in my Swift iOS app to save the user's data and keep it synced between devices. I did this successfully by first deleting the existing file and then writing the updated file, but I would like to use the writemode update instead as that seems safer and better. The one thing I can't figure out is what String to use in the call mode: .update(String). I tried using the same string as the path and that resulted in an error.

I hope this isn't a dumb question, but I've spent the last hour scouring google, the documention, and this forum and I can't seem to find this answer.

Thank you!

let encodedCompleteLibrary = try? JSONEncoder().encode(completeLibrary)
        
        if _inDropboxSyncMode, let client = DropboxClientsManager.authorizedClient {
            if let fileData = encodedCompleteLibrary {
                let pathString: String = UserDefaultsKeys.dropboxFolderName + UserDefaultsKeys.completeLibraryFilename
                client.files.upload(path: pathString, mode: .update(?????), autorename: false, mute: false, input: fileData)
                .response { response, error in
                    if let response = response {
                        self._inOfflineMode = false
                        print(response)
                    } else if let error = error {
                        self._inOfflineMode = true
                        print(error)
                    }
                }
            }
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Using the "update" mode is safer, and so it is recommended. The value you supply in it should be the "rev" value for the version of the file that you last downloaded and are updating, so that the server knows if you are working from the latest version or not.

    You can get the rev value from FileMetadata.rev, e.g., as returned by the download method.

    • chrismcqueen's avatar
      chrismcqueen
      Explorer | Level 4

      Awesome, thank you! I kept seeing "rev" and not knowing what that reffered to. I will give that a shot.

    • familyparker8's avatar
      familyparker8
      New member | Level 2

      hello


      Greg-DB wrote:

      Using the "update" mode is safer, and so it is recommended. The value you supply in it should be the "rev" value for the version of the file that you last downloaded and are updating, so that the server knows if you are working from the latest version or not.

      You can get the rev value from FileMetadata.rev, e.g., as returned by the download method.


       

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,876 PostsLatest Activity: 3 hours ago
325 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!