cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you interested in hearing how one of our Community members uses Dropbox for sailing trips? Read all about it 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: 

Objective C batch download

Objective C batch download

DboxDeveloper
Explorer | Level 3

Would just like to know if there is a batch download method available.

 

http://dropbox.github.io/dropbox-sdk-obj-c/api-docs/latest/Classes/DBFILESUserAuthRoutes.html#/c:obj...:

 

I have looked through the api but it doesn't seem to exist

 

And if its not. is a recursive download for batch files the optimal way to download batches of files?

 

-(void)recursiveDownload:(NSMutableArray<DBFILESMetadata *>*)array position:(int)position hasErrors:(BOOL)hasErrors {

    

    if (array.count == 0) {

        [self downloadCompletedAlert];

        return;

    }

    

    NSString* name = array[position].name;

    NSString* photoDropboxPath = [NSString stringWithFormat:@"/%@",name];

    NSURL* photoURLPath = [[WCPURLHelper applicationPhotoDirectory]URLByAppendingPathComponent:name isDirectory:NO];

    

     [[_dbUserClient.filesRoutes downloadUrl: photoDropboxPath overwrite:YES destination:photoURLPath]

      setResponseBlock:^(DBFILESFileMetadata *result, DBFILESDownloadError *routeError, DBRequestError *networkError,

                         NSURL *destination) {

          

          BOOL hasError = hasErrors;

          

          if (!result) {

              NSLog(@"%@\n%@\n", routeError, networkError);

              hasError = true;

          }

          

          _progressHUD.detailsLabelText = [NSString stringWithFormat:@"Downloading Photo %d of %zd",position+1,array.count];

          

          if (position+1 == array.count) {

              

              if (hasError) {

                  [self failedAlertWithDetailLabelText:@"Download Failed" title:@"Photos were not all downloaded" message:@"There were errors downloading from dropbox"];

              } else {

                  [self downloadCompletedAlert];

              }

          } else {

              //stops dropbox from giving the error that there are too many write actions happening

              //gives time between photos

              [self recursiveDownload:array position:position+1 hasErrors:hasError];

          }

      }];

}

1 Reply 1

Greg-DB
Dropbox Staff
The API doesn't offer a batch download call unfortunately, so you will need to loop through and call to download each file.
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?