问题
So I am in the process of switching over the Dropbox API from 1.0 endpoints, to 2.0 endpoints and running into an issue.
I was using the 1.0 endpoint https://api.dropboxapi.com/1/media/auto/ which gave me a nice direct URL for example: dropbox/blah/image.jpg
This allowed me to store the image directly (for up to 4 hrs) without having to DOWNLOAD the image itself
Now in 2.0 I have to use:
https://api.dropboxapi.com/2/files/get_temporary_link
This is a major issue as the link they supply has changed...it's no longer a direct .jpg link, it's come encoded URL like
https://dl.dropboxusercontent.com/apitl/1/AAA-TFdndE32VU-ruMMtCUyDIIczr71Wp8u7XmVA
which i can't hit directly in a web browser, it has some header content so it's an automatic download....
Does anyone know how I can get a direct link to the ACTUAL file without AUTO-DOWNLOADING? I Don't want the thumbnail either- that's too small.
回答1:
The link returned by API v2 is also a direct link (i.e., it returns the file data directly). However, it sets the Content-Disposition
to "attachment", so browsers will download it. There isn't an option for controlling this though.
回答2:
With v2 API, you can use a URL such as this:
https://content.dropboxapi.com/2/files/download?authorization=Bearer ACCESS_TOKEN&arg={"path":"/PATH/TO/THE/FILE"}
(encode the URL parameters properly)
In Javascript, it will be something like this:
var token = "...";
var path = "...";
var url = "https://content.dropboxapi.com/2/files/download"+
"?authorization="+encodeURIComponent("Bearer "+token)+
"&arg="+encodeURIComponent(JSON.stringify({path:path}))
来源:https://stackoverflow.com/questions/41387827/dropbox-api-v1-to-v2-regarding-direct-link