Cut the Clutter: Test Ignore Files Feature - sign up to become a beta tester here.

Forum Discussion

neunygph's avatar
neunygph
Explorer | Level 4
9 years ago

JavaScript SDK does not return thumbnails

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

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    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's avatar
    neunygph
    Explorer | Level 4
    9 years ago

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

    Thanks Greg

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,038 PostsLatest Activity: 6 years ago
415 Following

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 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!