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: 

Api v2 for filesGetThumbnail gives t.buffer not a function error

Api v2 for filesGetThumbnail gives t.buffer not a function error

pouic
Helpful | Level 6
Go to solution

Hi, when i try to get thumbnail for any file inside my folder i have the same error for different types os files (svg, png, ...)

 

 

  import { Dropbox } from 'dropbox';

let dbx = new Dropbox({ accessToken: 'my-key' }); dbx.filesListFolder({path: '/vector'}) .then(function(response) { console.log("file :" response.entries[0].path_display); dbx.filesGetThumbnail({ path: response.entries[0].path_display }) .then(function(response) { var fileUrl = URL.createObjectURL(response.fileBlob); var img = document.createElement('img'); img.setAttribute('src', fileUrl); document.getElementById('results').appendChild(img); }) .catch(function(error) { console.log(error); });

Every time have this error on console 

 

 

 

file: /vector/carro_preview.png

 

my-file.ts:47 TypeError: t.buffer is not a function
at Dropbox-sdk.min.js:1
at Dropbox-sdk.min.js:1
at t.invoke (polyfills.js:3)
at Object.onInvoke (core.js:4629)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.js:4620)
at t.invokeTask (polyfills.js:3)

1 Accepted Solution

Accepted Solutions

pouic
Helpful | Level 6
Go to solution

If import the DropboxSDK library like script import on my html works fine 😉

 

my solution: 

 

index.html ( add dropbox-sdk manually)

  <script src="assets/js/dropbox-sdk.js"></script>

On page where can use dropbox (index.ts)

declare var Dropbox: any;


  var dbx = new Dropbox.Dropbox({ accessToken: 'MY-KEY' });
   
    dbx.filesListFolder({path: '/my-folder-name'})
      .then(function(response) {

       dbx.filesGetThumbnail({ path: response.entries[0].path_display, format: 'png', size: 'w128h128' })
        .then(function(response) {
          var img = document.createElement('img');
          img.src=window.URL.createObjectURL(response.fileBlob);
          document.getElementById('results').appendChild(img);

        })
        .catch(function(error) {
          console.log(error);
        });
      
    });
  }

 

View solution in original post

5 Replies 5

Greg-DB
Dropbox Staff
Go to solution

pouic
Helpful | Level 6
Go to solution
I’m using ionic 2 with angular

Greg-DB
Dropbox Staff
Go to solution
Thanks! Those are probably relevant then. Can you try including the Dropbox library as a JavaScript library instead of a Node dependency?

pouic
Helpful | Level 6
Go to solution

If import the DropboxSDK library like script import on my html works fine 😉

 

my solution: 

 

index.html ( add dropbox-sdk manually)

  <script src="assets/js/dropbox-sdk.js"></script>

On page where can use dropbox (index.ts)

declare var Dropbox: any;


  var dbx = new Dropbox.Dropbox({ accessToken: 'MY-KEY' });
   
    dbx.filesListFolder({path: '/my-folder-name'})
      .then(function(response) {

       dbx.filesGetThumbnail({ path: response.entries[0].path_display, format: 'png', size: 'w128h128' })
        .then(function(response) {
          var img = document.createElement('img');
          img.src=window.URL.createObjectURL(response.fileBlob);
          document.getElementById('results').appendChild(img);

        })
        .catch(function(error) {
          console.log(error);
        });
      
    });
  }

 

Greg-DB
Dropbox Staff
Go to solution
The original `t.buffer is not a function` issue should be fixed in the latest version of the library, currently v4.0.3.
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    pouic Helpful | Level 6
What do Dropbox user levels mean?