Reputation: 178
I have an app that uses the Google Drive API, and I need to display the thumbnails. But when I pass the link to an <img>
tag it responds with a 404, but if I open the link manually in another tab in my browser it display just fine
Upvotes: 1
Views: 1394
Reputation: 201713
404
is returned. But when you directly access to the URL of the thumbnail link, you can see the image on your browser.I believe your goal and your issue like above. For this, how about this answer?
From your situation, I think that when you directly access to the thumbnail link, you might have logged in Google Account. By this, the image can be seen. And also, I thought that you might have used the following thumbnail link. This is the thumbnail link retrieved by Drive API.
https://docs.google.com/feeds/vt?gd=true&id={fileId}&v=1&s=###&sz=s220
Unfortunately, it seems that this link cannot be directly used at the HTML of outside. So in order to use the thumbnail at the HTML of outside, how about changing the endpoint?
https://drive.google.com/thumbnail?sz=w640&id={fileId}
{fileId}
of your file ID.w640
means 640 pixels in the width. If you want to change the height, please useh
instead of w
.On - Anyone with the link
. By this, above link can be used. Please be careful this.When the following HTML is used with the above link, the thumbnail can be seen.
<img src="https://drive.google.com/thumbnail?sz=w640&id={fileId}">
Upvotes: 3