Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Roshan B.1's avatar
Roshan B.1
New member | Level 1
10 years ago

Multiple getFile - PHP

Hi,

I'm currently making a website that requires multiple images to be downloaded with the dropbox API in one go (up  to 300 at a time).

Currently I am using this code, however I only ever seem to be able to download 46 images at a time before it stops. (I even tried upping max execution time)

I'm working on making it just put the files into a DB and periodically just update from there but that seems highly inefficient.

Is there a call to fetch multiple files in one go?

My current code:

if($delta['has_more'] == 1){//if new files are present
print_r($delta['has_more']);
foreach($delta['entries'] as $entry){
print_r($entry['0']);
echo '<hr/>';
if($entry['1'] == null){
unlink(basename($entry['0']));
}else{
if($entry['1']['is_dir'] != 1){//if not a directory
//save new file
$path = $entry['1']['path'];
$filename = basename($path);
$output = '/var/www/vhosts/MY/DOMAIN/images/dropbox/'.$filename;
$f = fopen($output, "w+b"); // write to $output
$fileImage = $dbxClient->getFile($path, $f);
fclose($f);
}
}
}
}

1 Reply

Replies have been turned off for this discussion
  • No, there's no API method to download multiple files in a single request.

    What do you mean when you say "it stops"? Is there some sort of error?

    The first line of this code seems wrong... has_more means there will be more entries if you call delta again. I also don't see the loop where you're calling delta for more entries.

    The logic should be something like this (pseudocode):

    has_more = true
    while(has_more)
    result = delta()
    has_more = result['has_more']
    process_entries(result.entries)

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

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, Facebook or Instagram.

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!