cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

get thumbnail from myfiles

get thumbnail from myfiles

mitr1887
Explorer | Level 3

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) {

    });
}
1 Reply 1

Greg-DB
Dropbox Staff

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.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?