Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
pouic
8 years agoHelpful | Level 6
Api v2 for filesGetThumbnail gives t.buffer not a function error
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)
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); }); }); }
5 Replies
Replies have been turned off for this discussion
- Greg-DB8 years ago
Dropbox Community Moderator
What environment is this running in?
There are some potentially related threads here:
- https://github.com/dropbox/dropbox-sdk-js/issues/178
- https://www.dropboxforum.com/t5/API-support/utilisation-de-l-API-filesGetThumbnail/m-p/267013
- https://www.dropboxforum.com/t5/API-support/Api-v2-for-filesGetThumbnail-gives-t-buffer-not-a-function-error/m-p/264234
- https://github.com/dropbox/dropbox-sdk-js/issues/172
- pouic8 years agoHelpful | Level 6I’m using ionic 2 with angular
- Greg-DB8 years ago
Dropbox Community Moderator
Thanks! Those are probably relevant then. Can you try including the Dropbox library as a JavaScript library instead of a Node dependency? - pouic8 years agoHelpful | Level 6
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-DB8 years ago
Dropbox Community Moderator
The original `t.buffer is not a function` issue should be fixed in the latest version of the library, currently v4.0.3.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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, Facebook or Instagram.
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!