7

I'm trying to get the thumbnail of a file but am getting an error 404, the url that return drive is like this in some files

https://docs.google.com/feeds/vt?gd=true&id=1DnoJzxnZXVERyqC5jfTwfpd8uEn&v=39&s=AMedNnoAAAAAUL0gv5da9U81UzT-L4N59b1BwNuZmzgU&sz=s220

but in others is

https://lh6.googleusercontent.com/ACwqFdvBX0NUJO6SR9fyemnCnSel-TpCZTaddu9CEkZqxtQpJY84cP_cFj64CA6=s220

the last one is from picasa and works, so apparently the url's that works are from picasa, how can i get the url's of all files like the last one?

Alexander
  • 261
  • 2
  • 16

2 Answers2

10

I ran into the same issue.

You should append access token to the thumbnailLink URL, which will authorize your GET request for it.

So something like:

var thumbLink = driveEntry["thumbnailLink"] + "&access_token=" + YOURTOKEN;

Cheers.

Timur K
  • 415
  • 5
  • 9
  • 1
    In one case, I am building out an application that selectively shows certain files, and not all files the user (through oauth2) has access to. One downside to this approach is that the access token is revealed to the end user, potentially requiring a proxy solution to keep access token hidden AND still have the thumbnail capability. Thought it worth mentioning for others who find this. – ryanm Mar 27 '18 at 19:51
2

To get the thumbnail of a file stored on Google Drive you have to send a GET request to the file endpoint and then check its thumbnailLink property:

https://developers.google.com/drive/v2/reference/files/get

Regardless of the format of the thumbnail URL, as long as you use the value returned in the file metadata you should be fine.

Please take into account that thumbnail URLs expire after a certain time.

Claudio Cherubino
  • 14,896
  • 1
  • 35
  • 42
  • Thx for you answer , but i'm doing exactly what you say , but some thumbnail URL are broken, and show a 404 error when is open. that is supposed to pass? get the thumbnailLink property and open that link and that show a 404 error? – Alexander Dec 04 '12 at 12:07
  • Are you trying to open the thumbnail with another user that is not allowed to see the document? – Claudio Cherubino Dec 04 '12 at 18:17
  • nop is the same user, i'm getting the access_token of the user, using the drive sdk, and getting the files, but some thumbnail URL are broken. if i upload some new files to drive , the thumbnail URL of that files works fine, but in some old files the thumbnail URL that gives the thumbnailLink property is broken show 404 error. – Alexander Dec 05 '12 at 03:14
  • Cant we get thumbnail if we don't have session. Mine is a case where we need list to show in some google site, all these are documents with permissions open. https://docs.google.com/folderview?id=0BxAXtL8YEO-cX2NOZkNpUUNoRzQ – sandeep koduri Dec 18 '14 at 22:34
  • @sandeepkoduri that would expose sensitive data since you could read a document from the thumb. – koma Jan 13 '15 at 20:25