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
janhec
4 years agoHelpful | Level 6
Easiest way to get (dropbox) file datetime using a dropbox link
Hi All,
I share a project I'm working on through some executables on dropbox, which users get a link to, so they can download.
I prefer, obviously, that they have an account, so they will have automatic synchronization to these frequently changed files.
However, some do not want to install dropbox and now I'm writing a mini-application (C++ using curl) to download, if necessary, the file(s) before starting the application.
Download is no problem with a the help of some specific curl parameters and the tag dl=1 and I can get some file information (notably the size) through the same proces using the curl parameter NOBODY. I would like to get the datetime, so I can decide automatically whether a full download is necessary. However, the file datetime stamp seems not to be present (the date shown below is date time of request),
(with minor redactions):
HTTP/1.1 200 OK
Server: envoy
Date: Tue, 22 Dec 2020 15:19:52 GMT
Content-Type: application/binary
Content-Length: 3943424
Cache-Control: max-age=60
Pragma: public
X-Dropbox-Request-Id: 81328b5452374573a93f7ddfb328d93b
X-Robots-Tag: noindex, nofollow, noimageindex
Referrer-Policy: no-referrer
Etag: 1609568595538751d
X-Content-Type-Options: nosniff
Accept-Ranges: bytes
Content-Disposition: attachment; filename="myfile.exe"; filename*=UTF-8''myfile.exe
Content-Security-Policy: sandbox
X-Webkit-Csp: sandbox
X-Content-Security-Policy: sandbox
Vary: Origin
X-Server-Response-Time: 394
Strict-Transport-Security: max-age=31536000; includeSubDomains
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Robots-Tag: noindex, nofollow, noimageindex
I then started trying the metadata interface e.g. (from cmd):
curl -X POST https://api.dropboxapi.com/2/files/get_metadata --data "{\"path\": \"id:4uo2ukwz6z9xvb3\",\"include_media_info\": false,\"include_deleted\": false,\"include_has_explicit_shared_members\": false}", but obviously get:
Error in call to API function "files/get_metadata": Must provide HTTP header "Authorization" or URL parameter "authorization".
Before delving deeper into this auth I would like to ask the question: Is there a simple(r) way to obtain file date time using the dropbox link for downloading or another method avoiding additional overhead? Clearly the people downloading are not getting any personal authorization info, so the only recourse is the link, which, as everyone knows, looks like https://www.dropbox.com/s/i1x59cj1zrs8cva/filename.ext?dl=0.
Thanks in advance,
Jan
Using the /2/sharing/get_shared_link_metadata endpoint is the right way to get metadata from a shared link, but that does require an access token, as you found.
There isn't another way to get the modified time of the file from the shared link directly, but you could instead use that "etag" value returned with that 200 response when accessing the shared link. You can store the etag for the version of the file you last downloaded, and before downloading it again, check the current etag value. If the etag value hasn't changed, that means that the content hasn't changed.
- Greg-DBDropbox Staff
Using the /2/sharing/get_shared_link_metadata endpoint is the right way to get metadata from a shared link, but that does require an access token, as you found.
There isn't another way to get the modified time of the file from the shared link directly, but you could instead use that "etag" value returned with that 200 response when accessing the shared link. You can store the etag for the version of the file you last downloaded, and before downloading it again, check the current etag value. If the etag value hasn't changed, that means that the content hasn't changed.
- janhecHelpful | Level 6
Greg-DB ,
Thank you.
That is quite helpful and probably sufficient. I'll tag it as a solution.
But it still surprises me that the last modified date is not given, and also not shown in de preview/download page you get when clicking the ....?dl=0 link. I really think that it would be helpful for people to avoid downloading a file which is identical to a previously downloaded file. I would really hope that dropbox does not deem this sort of functionalitty to be reserved to account-holders only.
Thanks again,
Jan
- janhecHelpful | Level 6
Re: The identical code now yields no useful information (with regard to fileversion).
Etag has disappeared, X-Dropbox-Request-Id changes per request.So I'll ask, instead of ranting about lack of backward compatibility, what is the way to
check a shared linked file for new version without downloading it (and even then...).
Here's what I get now, since a few days and after unreliable/varying responses:
--------------------------
HTTP/1.1 200 OK
Content-Security-Policy: font-src https://* data: ; style-src https://* 'unsafe-inline' 'unsafe-eval' ; base-uri 'self' ; default-src https://www.dropbox.com/playlist/ https://www.dropbox.com/v/s/playlist/ https://*.dropboxusercontent.com/p/hls_master_playlist/ https://*.dropboxusercontent.com/p/hls_playlist/ ; frame-src https://* carousel: dbapi-6: dbapi-7: dbapi-8: dropbox-client: itms-apps: itms-appss: ; child-src https://www.dropbox.com/static/serviceworker/ blob: ; media-src https://* blob: ; connect-src https://* ws://127.0.0.1:*/ws ; report-uri https://www.dropbox.com/csp_log?policy_name=metaserver-whitelist ; form-action 'self' https://www.dropbox.com/ https://dl-web.dropbox.com/ https://photos.dropbox.com/ https://paper.dropbox.com/ https://showcase.dropbox.com/ https://www.hellofax.com/ https://app.hellofax.com/ https://www.hellosign.com/ https://app.hellosign.com/ https://docsend.com/ https://www.docsend.com/ https://help.dropbox.com/ https://navi.dropbox.jp/ https://a.sprig.com/ https://selfguidedlearning.dropboxbusiness.com/ https://instructorledlearning.dropboxbusiness.com/ https://sales.dropboxbusiness.com/ https://accounts.google.com/ https://api.login.yahoo.com/ https://login.yahoo.com/ https://experience.dropbox.com/ https://pal-test.adyen.com https://2e83413d8036243b-Dropbox-pal-live.adyenpayments.com/ ; img-src https://* data: blob: ; object-src 'self' https://cfl.dropboxstatic.com/static/ https://www.dropboxstatic.com/static/ ; worker-src https://www.dropbox.com/static/serviceworker/ blob: ; frame-ancestors 'self' ; script-src 'unsafe-eval' https://www.dropbox.com/static/api/ https://www.dropbox.com/page_success/ https://cfl.dropboxstatic.com/static/ https://www.dropboxstatic.com/static/ https://accounts.google.com/gsi/client https://canny.io/sdk.js https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/ 'unsafe-inline'
Content-Type: text/html; charset=utf-8
Pragma: no-cache
Referrer-Policy: strict-origin-when-cross-origin
Set-Cookie: gvc=NDA2MzQyMTE4OTgyOTM1NjUzMDg0NTY5MTk5MzEzNDEwMzgyNjQ=; Path=/; Expires=Mon, 15 May 2028 19:09:07 GMT; HttpOnly; Secure; SameSite=None
Set-Cookie: t=GwpLm07-vGJT-M6RXpRnzwJ8; Path=/; Domain=dropbox.com; Expires=Sat, 16 May 2026 19:09:07 GMT; HttpOnly; Secure; SameSite=None
Set-Cookie: __Host-js_csrf=GwpLm07-vGJT-M6RXpRnzwJ8; Path=/; Expires=Sat, 16 May 2026 19:09:07 GMT; Secure; SameSite=None
Set-Cookie: __Host-ss=mY4WgzA-Fo; Path=/; Expires=Sat, 16 May 2026 19:09:07 GMT; HttpOnly; Secure; SameSite=Strict
Set-Cookie: locale=en; Path=/; Domain=dropbox.com; Expires=Mon, 15 May 2028 19:09:07 GMT
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Robots-Tag: noindex, nofollow, noimageindex
X-Xss-Protection: 1; mode=block
Date: Wed, 17 May 2023 19:09:07 GMT
Strict-Transport-Security: max-age=31536000; includeSubDomains
Server: envoy
Cache-Control: no-cache, no-store
Vary: Accept-Encoding
X-Dropbox-Response-Origin: far_remote
X-Dropbox-Request-Id: d5e15471969948c685be3ae620c37c34
Transfer-Encoding: chunked------------------------------
Anyone?
- ugur_kayaardiNew member | Level 2
forget it bro, close and open again try. .)
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,880 PostsLatest Activity: 8 hours 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!