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

Keith B.7's avatar
Keith B.7
Helpful | Level 7
9 years ago

Using file revs in API 2

In API 1, whenever a file was uploaded, a file rev was provided in the meta-data's .rev property in the "did upload" delegate methods. In API 2, DBFILESFileMetadata has an equivalent .rev property - so far, so good.

 

But how do I use that file rev when uploading files? In API 1, the -uploadFile:toPathwithParentRevfromUploadId: and -uploadFile:toPath:withParentRev:fromPath: methods allowed you to pass a cached file rev into them so that you could overwrite the file without having to delete it first.

 

In API 2, none of the -upload methods in DBFILESRoutes seem to allow you to pass in a file rev, so how is this done? Is it something to do with DBFILESWriteMode? (I couldn't see that had any way to pass in a file rev, either, though.)

 

Thanks!

  • Keith B.7's avatar
    Keith B.7
    Helpful | Level 7

    Hmm, actually, looking more at DBFILESWriteMode, is the rev what you are supposed to pass into -initWithUpdate:?

     

    So, e.g.:

    NSString *rev = ... // rev cached from a previous upload or listFolder: result.
    DBFILESWriteMode *update = [[DBFILESWriteMode alloc] initWithUpdate:rev];
    
    DBUploadTask *uploadTask = [self.dropboxClient.filesRoutes uploadUrl:dropboxPath mode:update autorename:@NO clientModified:localModDate mute:@NO inputUrl:localFileURL];

    Is this correct, or is the rev added a different way?

     

      • Keith B.7's avatar
        Keith B.7
        Helpful | Level 7

        Thanks. I think there's a minor documentation mistake in the DBFILESWriteMode.h file that is what makes this unclear. For -initWithUpdate:, it says this:

         

        /// @param update Overwrite if the given "rev" matches the existing file's
        /// "rev". The autorename strategy is to append the string "conflicted copy" to
        /// the file name. For example, "document.txt" might become "document
        /// (conflicted copy).txt" or "document (Panda's conflicted copy).txt".

         

        This is a duplicate of the paragraph above it which explains the purpose of the method. Presumably this paragraph should instead state that a file rev should be passed in as the update parameter. (Likewise in the documentation page on the site.) Because of this, I was looking elsewhere to find where I needed to input the "given 'rev'".

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

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