Want to know more about Dash? Check out how Amy uses Dropbox and Dash to make her day easier here! 

Forum Discussion

DboxDeveloper's avatar
DboxDeveloper
Explorer | Level 3
8 years ago

Objective C batch download

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:objc(cs)DBFILESUserAuthRoutes(im)downloadUrl:rev:overwrite:destination:

 

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

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago
    The API doesn't offer a batch download call unfortunately, so you will need to loop through and call to download each file.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,019 PostsLatest Activity: 5 hours ago
402 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!