We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
Андрей Г.2
6 years agoExplorer | Level 4
download_zip api
please give me an example of working code on php for download_zip, I unfortunately did not find this
Андрей Г.2
6 years agoExplorer | Level 4
function dropbox_download_zip($folder_path, $file_name)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://content.dropboxapi.com/2/files/download_zip');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = "Authorization: Bearer " . DROPBOX_TOKEN . "";
$headers[] = "Dropbox-API-Arg: {\"path\": \"$folder_path\"}";
$headers[] = "Content-Type: application/octet-stream; charset=utf-8";
$headers[] = "User-Agent: api-explorer-client";
$headers[] = "Content-Length: 0";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
$zip_file_name = $file_name . '.zip';
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename=' . $zip_file_name);
header('Content-Length: ' . strlen($result));
echo $result;
die();
}
}I have this code but for large files (eg 300mb) there is an error 'allowed memory size of bytes exhausted', I think it is due to the large file size,
please tell me how you can make curl result immediately written to zip file
Greg-DB
Dropbox Community Moderator
6 years agoI can't really help with memory management on your system or with configuring third party clients as they're not made by Dropbox. That said, if you want to use curl to save to a local file on your server's local filesytem, you may want to use the 'CURLOPT_FILE' option.
About Discuss Dropbox Developer & API
Make connections with 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!