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

12 Replies 12

Greg-DB
Dropbox Staff
Go to solution

@bffy_smmmers The filesListFolder method doesn't return any file data or shared links. It only returns file metadata. The Dropbox API also doesn't return thumbnail links in general. If you want the original file data, you should call filesDownload. If you want a thumbnail of an image file, you should call filesGetThumbnail. Those return the requested data directly (via fileBlob or fileBinary), but not as a link.

bffy_smmmers
Explorer | Level 4
Go to solution

@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-DB
Dropbox Staff
Go to solution

 

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

 

 

Need more support?