cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We're back with another cheat sheet to make your 2022 easier than ever! Check out our tips 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: 

Get thumbnail with TypeScript

Get thumbnail with TypeScript

DavidM27
Explorer | Level 4

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

Re: Get thumbnail with TypeScript

Greg-DB
Dropboxer

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

Re: Get thumbnail with TypeScript

Greg-DB
Dropboxer

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.

Re: Get thumbnail with TypeScript

DavidM27
Explorer | Level 4

Thank you for your reply.

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

 

Re: Get thumbnail with TypeScript

Greg-DB
Dropboxer

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.

Re: Get thumbnail with TypeScript

bffy_smmmers
Explorer | Level 4

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 

Re: Get thumbnail with TypeScript

Greg-DB
Dropboxer

@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.

Re: Get thumbnail with TypeScript

bffy_smmmers
Explorer | Level 4

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

Re: Get thumbnail with TypeScript

bffy_smmmers
Explorer | Level 4

@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. 

Re: Get thumbnail with TypeScript

Greg-DB
Dropboxer

@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.

Re: Get thumbnail with TypeScript

bffy_smmmers
Explorer | Level 4

@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) 

Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    bffy_smmmers Explorer | Level 4
What do Dropbox user levels mean?
Need more support?