How to overwrite file with parent rev using Dropbox API in iOS?

瘦欲@ 提交于 2019-12-04 03:31:10
sumanth

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

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

In the uploadFile method set the withParentRev to nil.

sumanth

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!