Search code examples
iosobjective-cdropboxprogressdropbox-sdk

Track the progress using new Dropbox SDK (V2) with filesRoutes' downloadUrl:overwrite:destination: method


I am trying to download a large file with the new dropbox SDK.

My downloading code is something like this-

DBUserClient *client = [DBClientsManager authorizedClient];

[[client.filesRoutes downloadUrl:remotePath overwrite:YES destination:documentUrl] setResponseBlock:^(DBFILESFileMetadata *result, DBFILESDownloadError *routeError, DBRequestError *networkError, NSURL *destination) {    
        if(result){
            NSLog(@"File Downloaded");
            // open the file after being downloaded
        }
    }];

Previously I used to use the the DBRestClient class' loadMetadata method.

[restClient loadMetadata:path];

which in turn would trigger the some other delegate methods, one of which is

- (void)restClient:(DBRestClient*)client loadProgress:(CGFloat)progress forFile:(NSString*)destPath

in this method, I could track the progress of the file that is being downloaded.

How can I track my downloading progress in the setResponse Block? Thanks in advance.


Solution

  • You can use setProgressBlock to set a block to receive progress updates. There's an example here:

    https://github.com/dropbox/dropbox-sdk-obj-c#download-style-request