We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
neunygph
10 years agoExplorer | Level 4
Getting multiple thumbnails of multiple files at once ?
Is it possible to retrieve multiple thumbnails of multiple files at once ? I tried to make a request to https://photos.dropbox.com/thumbnails_batch just like the guide from https://blogs.dropbox.com/...
neunygph
10 years agoExplorer | Level 4
Hi Greg,
According to the document from https://www.dropbox.com/developers-v1/core/docs#thumbnails, I implemented the api v1 to get an image thumbnail and I got this and I am able to display the thumbnail with this active url https://api-content.dropbox.com/1/thumbnails/auto/IMG_8199.jpg?size=l&access_token={mytoken}. So I'm wondering if there is a replacement for v2 with a similar URL like the one from https://api-content.dropbox.com/1/thumbnails/auto/IMG_8199.jpg?size=l&access_token={mytoken}.
Thanks,
According to the document from https://www.dropbox.com/developers-v1/core/docs#thumbnails, I implemented the api v1 to get an image thumbnail and I got this and I am able to display the thumbnail with this active url https://api-content.dropbox.com/1/thumbnails/auto/IMG_8199.jpg?size=l&access_token={mytoken}. So I'm wondering if there is a replacement for v2 with a similar URL like the one from https://api-content.dropbox.com/1/thumbnails/auto/IMG_8199.jpg?size=l&access_token={mytoken}.
Thanks,
Greg-DB
Dropbox Community Moderator
10 years agoThat's a way of calling the API endpoint and supplying the credentials on the URL itself (instead of in a header), but the API call still returns the thumbnail data directly.
API v2 does also offer a way to do this as well as documented here under "Content-download endpoints" (i.e., using the 'authorization' and 'arg' URL parameters).
It's important to note thought that while it does technically produce a single URL that returns a thumbnail that can be accessed just via a GET request, it should be used with caution, as it could leak the access token. For example, you shouldn't use this technique client-side if the thumbnails are being shown to anyone other than the owner of the files, as the links contain the access token.
- neunygph10 years agoExplorer | Level 4Oh I see, thanks Greg for helping me to know more about the v2 API.
Phuong - neunygph10 years agoExplorer | Level 4Hi Greg,
One more question please. I tried a get request to this endpoint https://content.dropboxapi.com/1/thumbnails/auto/IMG_8199.jpg with authentication token in the header and it works great. My question is: Will this get endpoint continue to be supported after 6/28/2017 when the api v1 is turned off since the end point host is from v2 but it still contain 1/ in the url. Please advice.
Thanks, - Greg-DB10 years ago
Dropbox Community Moderator
The /1/thumbnails endpoint is part of API v1 and will not be available after API v1 is retired. (The different hosts, e.g., api-content.dropbox.com and content.dropboxapi.com, are not tied to specific versions of the API. They each currently serve both API v1 and API v2.) - neunygph10 years agoExplorer | Level 4Oh ok, thank you very much.
Phuong - neunygph10 years agoExplorer | Level 4Hi Greg,
You mentioned that the api v2 does offer a way to get thumbnail as v1 (https://content.dropboxapi.com/1/thumbnails/auto/IMG_8199.jpg?size=s&access_token={mytoken}. I tried it but it never worked for me without /1/thumbnails, I even tried to replace /1/thumbnails with /2/get_thumbnail but no use. Do you have any example url/endpoint where it's showing access token from the url other than the one from v1 so I can look at ?
Thanks, - Greg-DB10 years ago
Dropbox Community Moderator
The different versions of the API work differently, so it won't be a matter of just replacing /1/thumbnails with /2/get_thumbnail. For API v2, you'll need to use the 'authorization' and 'arg' URL parameters, per the documentation I linked to earlier:
https://www.dropbox.com/developers/documentation/http/documentation#formats
For example, getting the thumbnail for a files at /test.jpg would look like this:
https://content.dropboxapi.com/2/files/get_thumbnail?authorization=Bearer%20ACCESS_TOKEN_HERE&arg=%7B%22path%22%3A%20%22%2Ftest.jpg%22%2C%22format%22%3A%20%22jpeg%22%2C%22size%22%3A%20%22w64h64%22%7D
- neunygph10 years agoExplorer | Level 4Hi Greg,
I tried the provided url with my token and an actual image path, but I got a weird error message saying "Error in call to API function "files/get_thumbnail": Your app is not currently allowed to use API v2". Wonder how this happens since I have been using v2, it's not that my app is still on development mode, I haven't submitted/requested for production yet. Wonder if this is why.
Thanks, - Greg-DB10 years ago
Dropbox Community Moderator
That error isn't related to your app's development or production status. Did you potentially use an access token for an app with the "file type" permission though (as opposed to full Dropbox or app folder)? The file type permission isn't supported by API v2. - neunygph10 years agoExplorer | Level 4I replaced the token and it worked, but I'm actually looking for endpoint that return image/jpeg or image/png Content-Type like v1, not application/octet-stream. Is it even possible to do it with the api v2 ?
I am aware that the api does not support returning thumbnails/templinks in bulk from the thumbnail and templink end points. But since the api support returning metadata in bulk from the list_folder endpoint, therefore I wonder if there is a way to include templinks or thumbnails from list_folder response that is not defined from the official api document.
Thanks, - Greg-DB10 years ago
Dropbox Community Moderator
The Content-Type header is reported differently (image/ in v1, and application/octet-stream in v2) but the actual thumbnail data returned is the same. Is the Content-Type header itself causing issues in your use case? I'll be happy to pass this along as feedback, but additional context would be helpful
Anyway, no, there isn't another way for getting temporary links or thumbnails like you describe that I can offer.
- neunygph10 years agoExplorer | Level 4Hi Greg,
I was able to implement the get/post thumbnails end point with "https://content.dropboxapi.com/2/files/get_thumbnail?authorization=Bearer%20ACCESS_TOKEN_HERE&arg=%7B%22path%22%3A%20%22%2Ftest.jpg%22%2C%22format%22%3A%20%22jpeg%22%2C%22size%22%3A%20%22w64h64%22%7D" successfully, but the returned data is a raw data.
For instance if I paste this "https://content.dropboxapi.com/1/thumbnails/auto/test.jpg?size=s&access_token={mytoken} into the address bar from a browser, I can be able to see the image directly from the browser.
But if I do the same step with this "https://content.dropboxapi.com/2/files/get_thumbnail?authorization=Bearer%20ACCESS_TOKEN_HERE&arg=%7B%22path%22%3A%20%22%2Ftest.jpg%22%2C%22format%22%3A%20%22jpeg%22%2C%22size%22%3A%20%22w64h64%22%7D", I can not see the image directly from the browser, and it will download raw data instead of showing the image i want to see on the browser.
Am I missing any step and/or arg or that's how it should be and there is no way we can display image directly on a browser with endpoint v2 ? - Greg-DB10 years ago
Dropbox Community Moderator
Thanks! That behavior is expected (potentially dependent on the browser itself though) because the browser doesn't know that the data is an image it can display in the v2 case.
Is that your app's actual use case though? That is, would the user be opening these in their browser directly like this (as opposed to say, using it in an img src)? - neunygph10 years agoExplorer | Level 4Hi Greg,
Yea, it is my app actual use case. I'm trying to display multiple thumbnails of photo from users selected folder or root folder when they open a page, regardless root folder or sub directories. It would take longer to load the whole page if we have to go through image processing from raw data, imagine if a user selects a sub folder with hundreds or thousands of photos, then I would have to process/download hundreds or thousands time to handle the photo from returned raw data.
The performance/page load time would be much better if I can get photo url or image/jpg or image/png content type. That's why I"m trying to find a way to display photo directly in browser from api response. - Greg-DB10 years ago
Dropbox Community Moderator
I see, thanks for the context!
For reference, while the browser will download the file when the URL is accessed directly due to the Content-Type, it looks like using it as a src for an img tag does work, so that may be a usable solution. (Again though, make sure you don't leak the access token to other users.) - neunygph10 years agoExplorer | Level 4Thanks for the tips and advice. I will give it a try :)
- Greg-DB9 years ago
Dropbox Community Moderator
I just wanted to follow up on this to let you know that the Dropbox API now offers the ability to get thumbnails in batches:
https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail_batch - neunygph9 years agoExplorer | Level 4
Oh this is a great news, thanks Greg for the update.
Phuong
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!