Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
yvancoyaud
8 years agoHelpful | Level 6
utilisation de l'API filesGetThumbnail
Bonjour,
Je suis au début de mes essais du SDK javascript de Dropbox et j'ai le problème suivant:
Le contexte :
<head>
<title>testDropbox</title>
<script src="https://unpkg.com/dropbox/dist/Dropbox-sdk.min.js">
</script>
</head>
<body>
<h1>Welcome to testDropbox</h1>
</body>
var Dropbox = require('dropbox').Dropbox;
let dbx = new Dropbox({accessToken:'MY_TOKEN'}); // siteyc
dbx.filesListFolder({path: '/musiques/Calypso_Rose'})
.then(function(response) {
console.log(response);
dbx.filesGetThumbnail({"path": "/IMG91.jpeg"})
.then(function (response) {
var img = document.createElement('img');
img.src=window.URL.createObjectURL(response.fileBlob);
document.body.appendChild(img);
})
.catch(function (error) {
console.log("got error:");
console.log(error);
})
.catch(function (error) {
console.log(error);
});
});
Et j'ai l'erreur :
TypeError: t.buffer is not a function
at modules.js?hash=766e2ef4550445d16370e789a864189070692cbb:1007
at meteor.js?hash=c9a34f92f28ede5a42eac467d3fa1763b624436a:1168
at <anonymous>
Je n'arrive pas a trouver de solution sur internet.
Quelqu'un peut petètre maider ?
Merci
YC
Mille merci, ça fonctionne.
Je remets ci-dessous le code si cela peut servir à d'autres développeurs sous Meteor.
Dabord :
$ meteor npm i dropbox -s
va inclure dans l'environnement du projet Meteor, "dropbox" et "dropbox-sdk"
<head> ..... <script src="https://unpkg.com/dropbox/dist/Dropbox-sdk.min.js"></script> ..... </head>let dbx = new Dropbox.Dropbox({accessToken:'MY_APP_TOKEN'}); dbx.filesListFolder({path: ''}) .then(function(response) { console.log(response) dbx.filesGetThumbnail({"path": "/IMG90.jpeg"}) .then(function(response) { var img = document.createElement('img'); img.src=window.URL.createObjectURL(response.fileBlob); document.body.appendChild(img); }) .catch(function(error) { console.log("got error:"); console.log(error); }); }) .catch(function (error) { console.log(error); })Voila cette configuration fonctionne pour moi.
Merci encore à Greg K.
YC
7 Replies
Replies have been turned off for this discussion
- Greg-DB8 years ago
Dropbox Community Moderator
Cela dépend de l'environnement dans lequel vous exécutez et de la manière dont vous importez la bibliothèque. Il y a quelques fils connexes:
https://www.dropboxforum.com/t5/API-support/Installations/m-p/263451#M15391
https://github.com/dropbox/dropbox-sdk-js/issues/172
https://github.com/dropbox/dropbox-sdk-js/issues/178En bref, je vois que vous importez la bibliothèque à la fois comme une bibliothèque JavaScript, ainsi qu'une bibliothèque de nœuds. Essayez de l'importer uniquement en tant que bibliothèque JavaScript.
---
S'il vous plaît excusez nos traductions. Nos traductions ont été créées en utilisant un traducteur en ligne. Nous aimerions soutenir toutes les langues, mais nous ne sommes pas équipés pour le faire. Voici la version anglaise:
---
Please excuse our translations. Our translations were created using an online translator. We'd like to support every language, but we're not currently equipped to do so. Here is the English version:
---
This depends on what environment you're running in, and how you import the library. There are a few related threads:
https://www.dropboxforum.com/t5/API-support/Thumbnails/m-p/263451#M15391
https://github.com/dropbox/dropbox-sdk-js/issues/172
https://github.com/dropbox/dropbox-sdk-js/issues/178In short, I see you're importing the library both as a JavaScript library, as well a Node library. Please try only importing it as a JavaScript library.
- yvancoyaud8 years agoHelpful | Level 6
Merci de votre réponse,
mais qu'appelez vous une bibliothèque de nœuds ?? par rapport a une biliothèque javascript ?
- Greg-DB8 years ago
Dropbox Community Moderator
L'importation de Node dont je parle est la `require ('dropbox')` dans votre code, et l'importation JavaScript à laquelle je fais référence est le `<script src=... `dans votre code.
---
The Node import I'm referring to is the `require('dropbox')` in your code, and the JavaScript import I'm referring to is the `<script src=...` in your code.
- yvancoyaud8 years agoHelpful | Level 6
Bonjour, suite,
Si j'enlève le
<script src="https://unpkg.com/dropbox/dist/Dropbox-sdk.min.js"></script>
du head, ça ne change rien !!! un peu comme si ligne était inutile ...
Si j'enlève le
var Dropbox = require('dropbox').Dropbox;
bien sûr j'ai une autre erreur qui me dit 'Dropbox is not a constructor' ce qui me semble normal.
Je suis un peu perdu et rien de bien clair les forums meme sur Stack Overflow.
Vos lumières m'aideraient vraiment.
Merci
YC
- Greg-DB8 years ago
Dropbox Community Moderator
Lorsque vous supprimez la ligne `var Dropbox = require ('dropbox'). Dropbox;` line, vous devez changer la façon dont vous accédez au constructeur. Au lieu de `new Dropbox`, faites` new Dropbox.Dropbox`.---When you remove the `var Dropbox = require('dropbox').Dropbox;` line, you will need to switch how you access the constructor. Instead of `new Dropbox`, do `new Dropbox.Dropbox`.
- yvancoyaud8 years agoHelpful | Level 6
Mille merci, ça fonctionne.
Je remets ci-dessous le code si cela peut servir à d'autres développeurs sous Meteor.
Dabord :
$ meteor npm i dropbox -s
va inclure dans l'environnement du projet Meteor, "dropbox" et "dropbox-sdk"
<head> ..... <script src="https://unpkg.com/dropbox/dist/Dropbox-sdk.min.js"></script> ..... </head>let dbx = new Dropbox.Dropbox({accessToken:'MY_APP_TOKEN'}); dbx.filesListFolder({path: ''}) .then(function(response) { console.log(response) dbx.filesGetThumbnail({"path": "/IMG90.jpeg"}) .then(function(response) { var img = document.createElement('img'); img.src=window.URL.createObjectURL(response.fileBlob); document.body.appendChild(img); }) .catch(function(error) { console.log("got error:"); console.log(error); }); }) .catch(function (error) { console.log(error); })Voila cette configuration fonctionne pour moi.
Merci encore à Greg K.
YC
- Greg-DB8 years ago
Dropbox Community Moderator
Le problème d'origine `t.buffer n'est pas une fonction` devrait être corrigé dans la dernière version de la bibliothèque, actuellement v4.0.3.
---
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!