Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
vibh
8 years agoExplorer | Level 3
API V2 Upload Limit
Hi, I am trying to upload the file to Dropbox using API v2 in PHP using curl. I am getting a 413 error response from the Dropbox server (Request entity too large). So what is the limit to upl...
thelwang
8 years agoHelpful | Level 7
vibh,
You seem to be doing things all yourself with curl. It might be easier for you to use some PHP bindings to the Dropbox API that someone else has made.
There doesn't seem to be an official Dropbox PHP binding, but this looks popular and sort of active on github: https://github.com/kunalvarma05/dropbox-php-sdk
You can see it uses upload sessions so that you can upload files larger than 100MB piece by piece://github.com/kunalvarma05/dropbox-php-sdk/blob/master/src/Dropbox/Dropbox.php#L780
To install it, full their instructions here. You might first have to install php composer to use this though, documentation for that is here.
If you're getting stuck on implementing an API just from the HTTP spec...I'd really recommend using an SDK since you'll likely just continue to have problems as you start using other Dropbox API features.
vibh
8 years agoExplorer | Level 3
Hi,
Thanks for your response.
$api_url = 'https://content.dropboxapi.com/2/files/upload_session/start';
to above API my code is:
$headers = array('Authorization: Bearer ' . $token,
'Content-Type: application/octet-stream',
'Dropbox-API-Arg: '.
json_encode(
array(
"close"=>false,
)
),
'Content-Type: application/octet-stream'
);
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
$path = $destPath . $to_zip_folder;
//echo $path;die;
$fp = fopen($path, 'rb');
$filesize = filesize($path);
curl_setopt($ch, CURLOPT_POSTFIELDS, fread($fp,$filesize));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1); // debug
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
response === {"session_id": "AAAAAAAAAFAB2YI_TkrUgw"}
http_code === 200
$api1_url = 'https://content.dropboxapi.com/2/files/upload_session/append_v2';
to above API my code is:
$headers1 = array('Authorization: Bearer ' . $token,
'Content-Type: application/octet-stream',
'Dropbox-API-Arg: '.
json_encode(
array(
"cursor"=>$w,
"close" => false,
)
),
'Content-Type: application/octet-stream'
);
$ch = curl_init($api1_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers1);
curl_setopt($ch, CURLOPT_POST, true);
$path = $destPath . $to_zip_folder;
//echo $path;die;
$fp = fopen($path, 'rb');
$filesize = filesize($path);
curl_setopt($ch, CURLOPT_POSTFIELDS, fread($fp,$filesize));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1); // debug
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
response === null
http_code === 200
$api2_url = 'https://content.dropboxapi.com/2/files/upload_session/finish';
to above my code is:
$headers2 = array('Authorization: Bearer ' . $token,
'Content-Type: application/octet-stream',
'Dropbox-API-Arg: ' .
json_encode(
array(
"cursor"=>$w1,
"commit"=>$q,
)
),
'Content-Type: application/octet-stream'
);
$ch = curl_init($api2_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers2);
curl_setopt($ch, CURLOPT_POST, true);
$path = $destPath . $to_zip_folder;
//echo $path;die;
$fp = fopen($path, 'rb');
$filesize = filesize($path);
curl_setopt($ch, CURLOPT_POSTFIELDS, fread($fp,$filesize));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1); // debug
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
http_code === 413
Please help.
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!