Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hi,
I am trying to get thumbnail of my dropbox files via api but I am not getting how can I show same or in what result I can access the same. Please help me.
In which format I would get thumbnails, where and how will I show it to Img tag
function getDocumentThumbnail(name, fileName, userObjectID, $callingFunctionSuccess) { var path = getDropboxPath(userObjectID); var params = { path: path + fileName } $.ajax({ cache: false, type: 'POST', url: 'https://content.dropboxapi.com/2/files/get_thumbnail', processData: false, contentType: 'application/octet-stream', headers: { 'Authorization': 'Bearer ' + Tenacious.authentication.getEmpData().DropboxToken, 'dropbox-API-Arg': JSON.stringify(params), }, }).done(function (data, e) { }).fail(function (data) { }); }
Using /2/files/get_thumbnail as you're doing here is the correct way to retrieve a thumbnail for a file from the Dropbox API.
Per the documentation, you can specify a 'format' parameter to request either 'jpeg' or 'png' for the format of the thumbnail. You're not specifying that, so you'll get the default of 'jpeg'.
This is a "content-download" endpoint, so the HTTP response body itself will contain the requested data, in this case, the raw data for the thumbnail. In your code, that's available in the 'data' parameter given to the 'done' callback function. Exactly what you do with that data is up to you.
Also, note that we do offer and recommend using the official Dropbox API v2 JavaScript SDK instead. That has a corresponding filesGetThumbnail method that you can use instead of calling the endpoint directly.
Hi there!
If you need more help you can view your support options (expected response time for a 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!