问题
I am developing an iOS application using Dropbox API. While uploading a file using the dropbox API, I just want to overwrite the existing file with the same name. How can I set the parent rev and what value? Thanks!
回答1:
Get all the files in the directory with [[self restclient] loadMetadata:@"/"]
in the delegate - (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata
you get all the details of each file.
Scan through all the files with file name of your interest and get the rev details with file.rev and store it.
When you want to replace the file, for parentrev argument, give the nsstring as what you stored with file.rev
回答2:
https://www.dropbox.com/developers/reference/api#files_put
Refering to the Dropbox API you just have to specify the parent_rev parameter. If you don't know the parent_rev, just call the https://www.dropbox.com/developers/reference/api#metadata for the file. In the response of that call, you will find the parent_rev
回答3:
In the uploadFile method set the withParentRev to nil.
回答4:
One more interesting way is
[[self restclient] loadrevisionsforfile:@"/test.pdf"]
This assume you know your test.pdf is under root directory
in the delegate
-(void) restclient:(DBRestClient *)client loadedRevisions:(NSArray *)revisions forfile:(NSString *)path
revisions array holds the history of all revisions of test.pdf file meaning the array count indicates the number of times test.pdf has been updated
DBMetaData *y = [revisions objectatindex:0]
At index 0, the revision number is the latest updated test.pdf.
For updating the existing test.pdf,y.rev can be used for argument in parentrev
来源:https://stackoverflow.com/questions/10682749/how-to-overwrite-file-with-parent-rev-using-dropbox-api-in-ios