Google Drive API 中缩略图的永久链接 [英] Permanent links to thumbnails in Google Drive API
问题描述
我正在使用 Google Drive API (PHP) 将一些照片上传到我的云端硬盘.上传文件时,会在响应中返回一个 Google_DriveFile
对象以确认传输成功.它包括一个名为 thumbnailLink
的字段,可通过 getThumbnailLink
getter 访问.它的内容可能如下所示:
I'm using Google Drive API (PHP) to upload some photos to my Drive. When a file is uploaded, a Google_DriveFile
object is returned in the response to confirm the successful transfer. It includes a field called thumbnailLink
, accessible through the getThumbnailLink
getter. Its content may look like this:
直到今天,我都确信链接不会随着时间的推移而自行改变.但是,当我尝试使用我保存在本地数据库中的缓存地址来显示我在云端硬盘上的照片的缩略图时,我收到了 403 错误 - 你可以在提到的链接下看到它.我向 API 询问了缩略图的当前链接,现在它完全不同了.
Until today, I was sure that the link doesn't change by itself over time. However, when I tried to display a thumbnail of a photo I have on my Drive, using a cached address I keep in my local database, I got a 403 error - you can see it under the mentioned link. I asked the API for the current link to the thumbnail and it's now completely different.
这种情况只发生在我身上一次,但针对多个文件,即我在云端硬盘上的所有文件突然有了新的缩略图链接.
It happened to me only once but for multiple files, i.e. all the files I had on my Drive suddenly got new thumbnail links.
有没有办法通过某个常数值快速检索文档(最好是照片)的缩略图或确保它不会改变?完美的解决方案是访问包含文档 id
的链接下的缩略图,而不是一些可能会更改的哈希.
Is there a way to quickly retrieve a thumbnail of a document (preferably, a photo) by some constant value or to be sure that it won't change? The perfect solution would be to access the thumbnail under a link that includes the document's id
instead of some hash that may change.
推荐答案
试试这个:
https://drive.google.com/thumbnail?authuser=0&sz=w320&id=[fileid]
地点:
sz
是一个尺寸,你可以使用w
(width), ash
(height)fileid
是文件 ID.您可以在 Google Drive UI 的分享"菜单中找到它.
sz
is a size, where you may use asw
(width), ash
(height)fileid
is a file id. You may find it in "share" menu by right click in Google Drive UI.
这篇关于Google Drive API 中缩略图的永久链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!