cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Share Link Redirect URL has no Content-Length

Share Link Redirect URL has no Content-Length

Roon
Explorer | Level 4
Go to solution

I'm trying to get the filesize from a shared link:

 

 

Looking at the answer to [this post] - the shared link creates a redirect to the file, which should provide a filesize in the headers.. 

It seems that the "Content-Length" Header is no longer available on the redirect link. 

 

Is there an alternative method?

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution
I don't believe there is a way to find out the size ahead of time unfortunately.

View solution in original post

7 Replies 7

Greg-DB
Dropbox Staff
Go to solution
My sample there is still returning Content-Length for me. Can you share a sample and output that isn't working as expected for you? Thanks in advance!

Roon
Explorer | Level 4
Go to solution

Hi Greg, 

 

heres my output 

$ curl -I https://www.dropbox.com/sh/j1msw4e8dup2c5q/AAANYUWXcyBDgxVGkveU7AFla?dl=1
HTTP/1.1 302 Found
Server: nginx
Date: Thu, 30 Nov 2017 11:03:23 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Cache-Control: no-cache
Content-Security-Policy: sandbox
Location: https://dl.dropboxusercontent.com/content_link_zip/liyObwdrElvSIeElexmq1AqHMTZhWtSFoGu0KKJOo63xs0INfWNSflheo9qjap41/file
Pragma: no-cache
Referrer-Policy: origin-when-cross-origin
Set-Cookie: locale=en; Domain=dropbox.com; expires=Tue, 29 Nov 2022 11:03:23 GMT; Path=/; secure
Set-Cookie: gvc=Mjk4NTU0NTY4OTI3NDA1ODI1NDAzMTI2Mjk5ODM5MTkxNzY2NDU0; expires=Tue, 29 Nov 2022 11:03:23 GMT; httponly; Path=/; secure
Set-Cookie: flash=; Domain=dropbox.com; expires=Thu, 30 Nov 2017 11:03:23 GMT; Path=/; secure
Set-Cookie: puc=; expires=Thu, 30 Nov 2017 11:03:23 GMT; httponly; Path=/; secure
Set-Cookie: bang=; Domain=dropbox.com; expires=Thu, 30 Nov 2017 11:03:23 GMT; Path=/; secure
Set-Cookie: t=Xdr_KsdQvptCBofiAcYwgGSY; Domain=dropbox.com; expires=Sun, 29 Nov 2020 11:03:23 GMT; httponly; Path=/; secure
Set-Cookie: __Host-js_csrf=Xdr_KsdQvptCBofiAcYwgGSY; expires=Sun, 29 Nov 2020 11:03:23 GMT; Path=/; secure
X-Content-Type-Options: nosniff
X-Dropbox-Request-Id: 760ad66de5a8c9aa75c7e535a0491e38
X-Frame-Options: DENY
X-Robots-Tag: noindex, nofollow, noimageindex
X-Xss-Protection: 1; mode=block
Strict-Transport-Security: max-age=15552000; includeSubDomains

 

and then if i try the redirect link directly (from the Location: xxx in the above)

 

$ curl -I https://dl.dropboxusercontent.com/content_link_zip/liyObwdrElvSIeElexmq1AqHMTZhWtSFoGu0KKJOo63xs0INfWNSflheo9qjap41/file
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 30 Nov 2017 11:03:45 GMT
Content-Type: application/zip
Connection: keep-alive
referrer-policy: no-referrer
x-robots-tag: noindex, nofollow, noimageindex
content-disposition: attachment; filename="AscentShared.zip"; filename*=UTF-8''AscentShared.zip
set-cookie: uc_session=ouN6cNB5FrD7Kf0nDpzHHCXY6wLIJFZ2rRVH6pmLHsdY1JLMkHnoHzPQBCKnG1Pw; Domain=dropboxusercontent.com; httponly; Path=/; secure
content-security-policy: referrer no-referrer
x-dropbox-request-id: d3e420b20a4f94e73d00a6cc078b74c7
pragma: public
cache-control: max-age=0
x-content-security-policy: referrer no-referrer
x-webkit-csp: referrer no-referrer
X-Server-Response-Time: 557
Strict-Transport-Security: max-age=15552000; includeSubDomains

deFreitas
New member | Level 2
Go to solution

Content-Length is not required, Your shared link is a folder then Dropbox is probably dynamically zipping it, that is probably the reason why it have not a length

Greg-DB
Dropbox Staff
Go to solution
That's correct, my sample was a link for a file, so it can offer a Content-Length. Your example is a link for a folder, which is compressed on the fly, so the Content-Length isn't available.

Roon
Explorer | Level 4
Go to solution
Thanks..
So I take that to mean that the compression is incomplete when the headers are sent.. and consequently there is no known size..
Leading me to the question, how am i supposed to know the compressed file-size of a folder prior to downloading it? (I need to indicate progress as a percentage)



Greg-DB
Dropbox Staff
Go to solution
I don't believe there is a way to find out the size ahead of time unfortunately.

sechel
Explorer | Level 3
Go to solution

Hey there,

there is an easy solution to this question: Do a HEAD request with a Range:bytes=0- header. Then you will have a Content-Length header in the response 😀 Hope that helps, greetings

Stefan

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    sechel Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Roon Explorer | Level 4
  • User avatar
    deFreitas New member | Level 2
What do Dropbox user levels mean?