You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Ze'ev G.
10 years agoNew member | Level 1
Get size without authenticating?
Can I get the size of a file via a CURL command given only a link without authenticating?
E.g.,
https://www.dropbox.com/s/uf12345szlap449/Files.mp4?dl=0
- Greg-DBDropbox Staff
Shared links like this (generally) don't require you to authenticate to access the content, so you can get the content and check the length. For example, using this link:
https://www.dropbox.com/s/vv7us05r9z46lwt/hello_world.txt?dl=0
We can ask for the raw file content by modifying the parameters as shown here:
https://www.dropbox.com/help/201
This gives us this version of the link:
https://www.dropbox.com/s/vv7us05r9z46lwt/hello_world.txt?raw=1
We can then access the content programmatically, e.g., using curl:
curl -L https://www.dropbox.com/s/vv7us05r9z46lwt/hello_world.txt?raw=1
(The -L is necessary to follow redirects.)
The response contains the length in the "Content-Length" header, e.g.:
Content-Length: 14
Alternatively, you can check the length of the returned file yourself.
Or, here's a more advanced method, using the Python requests library, to get the Content-Length without downloading the file, by using a HEAD request:
import requests url = "https://www.dropbox.com/s/vv7us05r9z46lwt/hello_world.txt?raw=1" redirected_url = requests.head(url).headers['location'] content_length = requests.head(redirected_url).headers['Content-Length'] print content_length
(Just don't re-use redirected_url. Always get a new one from the original link.)
- Ze'ev G.New member | Level 1
Thanks. That works, however, I had to use "curl -LI", otherwise it tries to download the entire file. And it worked fine with the original "dl=0" link as well.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,882 PostsLatest Activity: 3 years agoIf 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 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!