Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
DavidM27
6 years agoExplorer | Level 4
Get thumbnail with TypeScript
Hello,
I'm trying to get the thumbnail of an image with the js sdk implemented in a TypeScript application.
I'm using th method fileGetThumbnail() it return a Promise<DropboxTypes.files.FileMetaData> so once the promise is resolve I have an object of the type FileMetaData.
This is fine but the FileMetaData object does not have a fileBlob object in it but when I'm doing a console.log(response), I do have a fileBlob in it...
How am I supposed to get the thumbnail in my application without the blob ?
Thank you for any help
Using the "fileBlob" property is the right way to get the thumbnail data. Currently, you'll need to access it like this though: https://github.com/dropbox/dropbox-sdk-js/blob/master/examples/typescript/download/download.ts#L10
Apologies this isn't better documented or included in the TypeScript definitions! I'll ask the team to fix that up.
12 Replies
- bffy_smmmers5 years agoHelpful | Level 5
Greg-DB Thanks, and i am passing in the path to the file, correct? would that not mean the `path_lower` attribute? This does not yield any result for me. Here is my implementation. When i wrap it in a try/catch, i get the error (fetch is not a function) I apologize for not unerstanding, again, I'm new to this. Im trying to put my code in a block, but it gives me an error when i go to post.
async getThumbnail(path: any) {
console.log(`getThumbnail is running with ${path}`)
const data = await this.client.filesGetThumbnail(path)console.log(<any>data)
//im returning an empty string so it doesnt break anything
return '';}
- Greg-DB5 years ago
Dropbox Community Moderator
bffy_smmmers You should use .then and .catch to handle the result/error, like this:
dbx.filesGetThumbnail({path: path}) .then(function(response) { console.log("got filesGetThumbnail response:"); console.log(response); console.log("got thumbnail data:"); console.log(response.fileBlob); }) .catch(function(error) { console.log("got filesGetThumbnail error:"); console.log(error); });
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!