cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

Re: Get thumbnail with TypeScript

Get thumbnail with TypeScript

DavidM27
Explorer | Level 4
Go to solution

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

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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.

View solution in original post

12 Replies 12

Greg-DB
Dropbox Staff
Go to solution

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.

DavidM27
Explorer | Level 4
Go to solution

Thank you for your reply.

Is there any way for me to get to know when this is fixed ?

 

Greg-DB
Dropbox Staff
Go to solution

Yes, I'll follow up here once I have an update on that. I can't offer a timeline for a fix though, so please use the workaround for now.

bffy_smmmers
Explorer | Level 4
Go to solution

hi - is the above issue stil lthe case? the github link detailing the workaround doesnt work and i cannot get this to work at all on typescript. thank you! @Greg-DB 

Greg-DB
Dropbox Staff
Go to solution

@bffy_smmmers In browser contexts, you should access the file data using fileBlob like in this example. In node contexts, you should use fileBinary instead, like in this example.

bffy_smmmers
Explorer | Level 4
Go to solution

thanks @Greg-DB  - this is in a node context! i will give this a try. 

bffy_smmmers
Explorer | Level 4
Go to solution

@Greg-DB how exactly do i get access to the shared link that is needed? i dont see it being returned on `filesListFolder`. I dont quite understand what I'm meant to pass in in order to return it and use it to get the thumbnail on the node backend. In the example the user is prompted for the shared link. 

Greg-DB
Dropbox Staff
Go to solution

@bffy_smmmers Those examples happen to use sharingGetSharedLinkFile, which is a way to retrieve file data from a shared link. That's just an example though, and may not be the right method for your own use case, such as if you're not working from a shared link to begin with. There are other methods for other use cases, but other content download methods enable access to the resulting file data in the same way (i.e.,  via fileBlob or fileBinary).

 

So, for instance, if you just want to download a file from the connected account directly, not via a shared link, you would probably want to use the filesDownload method instead. You would pass in the path for the file that you want to download. You can get the path from elsewhere on the API, such as filesListFolder/filesListFolderContinue, etc.

bffy_smmmers
Explorer | Level 4
Go to solution

@Greg-DB  I'm essentially trying to get just a link to the thumbnail image from a file. Im calling on filesListFolder to get the contents of a folder, and i was hoping to pull off some piece of data from that to feed to sharingGetSharedLinkFile to get the thumbnail, but i dont see any clear/ simple way to do that (but i am a beginner and could be missing something) 

Need more support?