We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
mark2mark
8 years agoHelpful | Level 7
Expiration settings of Temporary Link
Hi all,
is there a way to set the expiration duration for a Temporary Link in the API? The generated one expires within 4 hours by default. I’m thinking of setting it to 24 hours or so. I’ve se...
Greg-DB
Dropbox Community Moderator
8 years agoNo, it's not possible to set arbitrary expirations on those temporary links, but I'll pass this along as a feature request.
Note that you can modify the shared links from sharing_create_shared_link_with_settings for different behaviors if that helps:
https://www.dropbox.com/help/desktop-web/force-download
Note that you can modify the shared links from sharing_create_shared_link_with_settings for different behaviors if that helps:
https://www.dropbox.com/help/desktop-web/force-download
mark2mark
8 years agoHelpful | Level 7
Thanks for the reply and for forwarding it as a feature request. I can imagine that others can benefit from it as well :)
- thelwang8 years agoHelpful | Level 7
mark2mark,
Greg already linked to the docs on this, but just to be clear...you don't have to use the UI for sharing_create_shared_link_with_settings type of links. If you get a shared link with that API and then replace "?dl=0" with "?raw=1" that links will function almost identically to the 4-hour temporary links. That'll probably work for you? The one caveat is that to access the full file data you'll have to follow a redirect or two first.
(something I've noticed is that Dropbox never serves the bytes of files directly from the www.dropbox.com. A file's bytes always come from different domain/subdomains)
(also it's pretty ugly that every shared link you get this way has "?dl=0" on it. It seems like it's just telling the server that dl (download) equals 0 (false) which is also the default. If you remove "?dl=0" the links still work fine but now you helpfully have the file/folder name at the end of the URL instead of that query args which is gobbleygook to the majority of people)
- mark2mark8 years agoHelpful | Level 7
Thanks for the replies!
I am a bit confused by the documentation and my result.import sys, json, datetime nowPlusAddedHours = datetime.datetime.now() + datetime.timedelta(hours=24) nowPlusAddedHours = str(nowPlusAddedHours.isoformat()[:19] + "Z") if (3,0) <= sys.version_info < (4,0): import http.client as httplib elif (2,6) <= sys.version_info < (3,0): import httplib headers = { "Authorization": "Bearer %s" % access_token, "Content-Type": "application/json" } params = { "path": "/FOLDER/FILE.zip", "settings": {"requested_visibility":{".tag":"public"},"expires":nowPlusAddedHours} } c = httplib.HTTPSConnection("api.dropboxapi.com") c.request("POST", "/2/sharing/create_shared_link_with_settings", json.dumps(params), headers) r = c.getresponse() print r.read()I know that my access token is valid, but i get an error:
{"error_summary": "settings_error/not_authorized/...", "error": {".tag": "settings_error", "settings_error": {".tag": "not_authorized"}}}
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!