What's the correct way of using the Google Drive thumbnails?

安稳与你 提交于 2019-12-10 18:22:30

问题


I've tried first to store and use the link the API returns, but it expires in a short amount of time. Then I tried to download and store the image locally (and serve it from my servers); but the thumbnail links throws a 404 error when I'm not logged in with my account (though the documents are fully public).

What's the correct way of serving/retrieving the thumbnail of a document?


回答1:


I finally solved the problem. You can download the thumbnails if you fetch the URL before it expires and you use an authenticated client (using the token you have to access the API). This last bit it's important, because a normal GET request will receive a 404 error otherwise.




回答2:


You need to add the Authorization header to the HTTP GET request for the thumbnailLink URL.

Authorization: OAuth [token]

Replace [token] with your OAuth token. Without the Authorization header, Google returns a 404 response. Keep in mind the link is not long lived, so you have to grab it quickly.



来源:https://stackoverflow.com/questions/12445335/whats-the-correct-way-of-using-the-google-drive-thumbnails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!