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
mattia o.
8 years agoNew member | Level 2
How use /get_thumbails response
Hi, I'm trying to figure out how I should use the response of the /get_thumbnail call. What I'm actually receiving are some raw data like the following: �����JFIF���������C�...
Greg-DB
Dropbox Staff
The get_thumbails endpoint returns the raw data for the thumbnail itself, and it looks like that's working properly for you.
What you do with that thumbnail data is up to you. For example, you can save it to a local file on your server and serve it in an img tag. Or, you may be able to convert it to base64 and use it in a data URI for the src for an img tag. Both of those are themselves unrelated to Dropbox itself though, so I'm afraid I can't offer too much insight there.
What you do with that thumbnail data is up to you. For example, you can save it to a local file on your server and serve it in an img tag. Or, you may be able to convert it to base64 and use it in a data URI for the src for an img tag. Both of those are themselves unrelated to Dropbox itself though, so I'm afraid I can't offer too much insight there.
slolal25
3 years agoNew member | Level 2
It is indeed raw file data! However, in this case it works similarly to opening a JPEG image in notepad and copying it into another empty notepad file and renaming the file extension to JPEG - you may notice that the second file will not display an image and return an error! Depending on what media you are using to copy and paste this binary data, it may store it incorrectly then paste the corrupted data.
I too had this same issue with many question marks showing up in the JFIF content-download returned from get_thumbnail API. I'm curious how it would work with DataURI but I was able to convert the returned JPEG/JFIF into an img tag by first converting it into a "blob" like below AND setting overrideMimeType to the "text/plain"
Below is a Javascript example using XMLHttpRequest that I used in my project:
const Http = new XMLHttpRequest();
const url = 'https://content.dropboxapi.com/2/files/get_thumbnail_v2';
//make sure that all text stays as plain text when read in...
Http.overrideMimeType('text/plain; charset=x-user-defined');
Http.open("POST", url);
Http.responseType = "blob";
Http.setRequestHeader('Authorization', 'Bearer ' + access_token_dropbox);
Http.setRequestHeader('Dropbox-API-Arg', JSON.stringify(data));
Http.send();
Http.onreadystatechange = (e) => {
if (Http.readyState === 4) {
let jpegData = Http.response;
var imageUrl = URL.createObjectURL(Http.response);
document.getElementById("firstDiv").innerHTML = `<img src="${imageUrl}" alt="jo mama" />`;
}}
I got this idea from another question posed here that had a similar issue and was resolved by changing xmlhttprequest.responseType to "blob"
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,910 PostsLatest Activity: 3 days 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!