We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
MarekKonderla
5 years agoNew member | Level 2
Ziping 1GB folder and downloading it as client
Hi, I have been experimenting with dropbox api on my PHP project and everything is working fine, until I try download bigger folders (cca 1GB). The downloadZip method from SDK is returning a huge bod...
MarekKonderla
5 years agoNew member | Level 2
So I have found a solution.
Example:
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: Binary");
header("Content-Disposition:attachment;filename=" . $album->name . '.zip');
$opts = [
'http' => [
'method' => "POST",
'header' => "Authorization: Bearer TOKEN\r\n" .
"Dropbox-API-Arg: ".json_encode([
"path" => $path
])."\r\n",
'body' => ''
]
];
$context = stream_context_create($opts);
$fp = fopen('https://content.dropboxapi.com/2/files/download_zip', 'r', false, $context);
fpassthru($fp);
exit();Which essentialy streams output of dropbox endpoint directly to a client, without a need to store it to memory.
About 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!