cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using file revs in API 2

Using file revs in API 2

Keith B.7
Helpful | Level 7

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 4

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?

 

Greg-DB
Dropbox Staff
That's correct.

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

Greg-DB
Dropbox Staff
I see, thanks for pointing that out!
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Keith B.7 Helpful | Level 7
What do Dropbox user levels mean?