Google Drive API中的缩略图的永久链接 [英] Permanent links to thumbnails in Google Drive API

查看:94
本文介绍了Google Drive API中的缩略图的永久链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google Drive API(PHP)将一些照片上传到我的云端硬盘。上传文件时,响应中会返回 Google_DriveFile 对象以确认传输成功。它包含一个名为 thumbnailLink 的字段,可通过 getThumbnailLink getter访问。其内容可能如下所示:



https ://lh4.googleusercontent.com/dqVdU195R4_0ZtWxsJlhW1Fr2K30xa2hH3V1KV4UrTBl9QkhOSR0ZqN9HoB-TjEQv8SIJw=s220



直到今天,我确信链接不会随着时间的推移而自行改变。但是,当我尝试显示我的云端硬盘上的照片的缩略图时,我使用缓存的地址保留在本地数据库中,但出现了403错误 - 您可以在提及的链接下看到它。我向API索取了缩略图的当前链接,现在它完全不同。



它只发生过一次,但对于多个文件,即所有文件我的云端硬盘突然有了新的缩略图链接。

有没有办法通过某个常量值快速检索文档的缩略图(最好是照片),或者确保它不会改变?完美的解决方案是在包含文档 id 的链接下访问缩略图,而不是一些可能会改变的散列。

解决方案

试试这个:
https://drive.google.com/thumbnail?authuser=0&sz=w320&id= [fileid]
其中:
- sz是可以用作w(宽度)的尺寸,作为h(高度)
- [fileid]是文件ID。您可以通过在Google Drive ui


中点击右键在分享菜单中找到它

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:

https://lh4.googleusercontent.com/dqVdU195R4_0ZtWxsJlhW1Fr2K30xa2hH3V1KV4UrTBl9QkhOSR0ZqN9HoB-TjEQv8SIJw=s220

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.

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.

解决方案

try this: https://drive.google.com/thumbnail?authuser=0&sz=w320&id=[fileid] where: - "sz" is a size, where you may use as "w" (width), as "h" (height) - [fileid] is a file id. you may find it in "share" menu by right click in google drive ui

这篇关于Google Drive API中的缩略图的永久链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆