cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

JavaScript SDK does not return thumbnails

JavaScript SDK does not return thumbnails

neunygph
Explorer | Level 4

I'm trying to use Dropbox SDK to retrieve an imge thumbnail with 

filesGetThumbnail method. I used

Dropbox.filesGetThumbnail and I received the response successfully but look like it only return the image's properties such as size, name, path..etc but there was no base64 encoded value in the return as expexted. I tried the same image with the API version 2 and it returned base64. Just wonder if this is a bug or an expected behavior from the SDK. 

1. If it's an expected behavior, is there a way to get image data such as base64 encoded or image URL/source. 

2. How do I get the response header in order to get the image's etag.

 

Thanks,

 

 

2 Replies 2

Greg-DB
Dropbox Staff

1. The filesGetThumbnail (and any other method that returns data in the response) makes the data available in the response's fileBlob property, if you're running in the browser, and fileBinary if you're running in node.

 

So, for example, you can do this:

dbx.filesGetThumbnail({path: remoteFilePath})
  .then(function(response) {
    console.log(response);
    console.log(response.rev);
    console.log(response.fileBlob);

    // do whatever you want with the data here, e.g.:
    objectURL = URL.createObjectURL(response.fileBlob)
    var downloadButton = document.createElement('a');
    downloadButton.setAttribute('href', objectURL);
    downloadButton.setAttribute('download', response.name);
    downloadButton.setAttribute('class', 'button');
    downloadButton.innerText = 'Download: ' + response.name;
    document.getElementById('results').appendChild(downloadButton);
  })
  .catch(function(error) {
    console.error(error);
  });

2. I covered this a bit in your other thread, but you should use the native properties on the response project. The code example above access the "rev", for instance.

neunygph
Explorer | Level 4

Oh I see, I did not realize the data is included in fileBlob.

Thanks Greg

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    neunygph Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?