Take Your Search Game to the Next Level with Dropbox Dash  🚀✨ Curious how it works? Ask us here! 

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!

4 Replies

  • 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'".