Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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 body, which cannot be printed (due to memory limit), so I have used fpassthru and succesfully downloaded zip as client, but there is a still huge amount of time consumed by the act of server downloading the response, which brings me to my question.
Is there a possibility in node js or php to start downloading file while script fetches data from dropbox?
Basically I would to start downloading instantly, but I am not even sure if it is possible.
I am also open to other solutions
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.
Hi there!
If you need more help you can view your support options (expected response time for a 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!