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's avatar
janhec
Helpful | Level 6
5 years ago

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.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,915 PostsLatest Activity: 2 days ago
333 Following

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 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!