简体   繁体   English

Google云端硬盘缩略图获得403限速率

[英]Google Drive Thumbnails getting 403 Rate-Limit Exceeded

We have an application with a library feature that shares photos/documents between users. 我们有一个具有库功能的应用程序,可以在用户之间共享照片/文档。 The basic flow and problem is as follows: 基本流程和问题如下:

  1. A user shares a file in the application which makes a file public unlisted. 用户在应用程序中共享文件,使文件不公开。
  2. Other users can request the list of files currently shared with the group. 其他用户可以请求当前与该组共享的文件列表。
  3. They then request the meta data the about any files they want to list, which includes a thumbnail url which we then display. 然后,他们向元数据请求他们想要列出的任何文件,其中包括我们随后显示的缩略图URL。

Usually the thumbnails come up just fine but sometimes we begin getting 403's. 通常缩略图很好但有时我们开始得到403。 After a while they will begin working again without us changing anything. 过了一会儿,他们将重新开始工作而我们不做任何改变。 A few other items worth mentioning are: 其他一些值得一提的项目是:

  1. The actual API calls never seem to hit any limits. 实际的API调用似乎永远不会达到任何限制。 We get this issue even when we are just requesting a single file. 即使我们只是请求单个文件,我们也会遇到此问题。 The console in Google doesn't show any exceeded limits as far as we can tell. 据我们所知,Google中的控制台没有显示任何超出限制。
  2. If you open up the thumbnail in a separate tab it always seems to come up without any problem. 如果您在单独的选项卡中打开缩略图,它似乎总是没有任何问题。
  3. When it goes into this mode all of our developers seem to hit it at the same time, hence we are guessing it is linked to some limit from our application but we can't seem to find any limits we are exceeding. 当它进入这种模式时,我们所有的开发人员似乎都在同一时间点击它,因此我们猜测它与我们的应用程序的某些限制有关但我们似乎无法找到任何我们超出的限制。 (Note: Our developers work from home so they all have different IP addresses.) (注意:我们的开发人员在家工作,因此他们都有不同的IP地址。)
  4. The details of our 403's can be found below. 我们403的细节可以在下面找到。

We are guessing it isn't related to the following: 我们猜测它与以下内容无关:

  1. Making too many requests concurrently since we get the problem even when we do a single file. 因为即使我们执行单个文件也会遇到问题,因此会同时发出太多请求。
  2. Not being authorized since (a) the files are public unlisted, (b) we just logged in, and (c) when you open the thumbnail in a tab it shows up just fine. 未经授权,因为(a)文件是公开的不公开的,(b)我们刚刚登录,(c)当您在标签中打开缩略图时,它显示正常。

Any ideas? 有任何想法吗?

403s的图像

在此输入图像描述

在此输入图像描述

在此输入图像描述

Screenshot of our Google Drive quotas 我们的Google云端硬盘配额的屏幕截图 在此输入图像描述

After a few days of experimentation, I'm pretty sure this is caused by accessing the URLs in question from a localhost environment. 经过几天的实验,我很确定这是因为从localhost环境访问有问题的URL。 Whenever I push to production, the quota limit resolves itself for thumbnails I'm attempting to access from Google. 每当我推向制作时,配额限制都会自动解决我试图从Google访问的缩略图。

While I don't have conclusive proof that this is the case, it definitely makes sense given the observed behavior. 虽然我没有确凿的证据证明这是事实,但鉴于观察到的行为,它绝对有意义。

My "solution" was to use the new referrerpolicy and set it to no-referrer in the image element. 我的“解决方案”是使用新的referrerpolicy并在image元素中将其设置为no-referrer

<img referrerPolicy="no-referrer" src="GOOGLE_THUMBNAIL_IMAGE_LINK"/>

The attribute is experimental according to MDN . 根据MDN,该属性是实验性的。 At time of writing, it's supported on Chrome and Firefox only, so not a real fix. 在撰写本文时,它仅支持Chrome和Firefox,因此不是真正的解决方案。 The theory behind it working is the no-referrer means the image request is the same as the one used when you go directly to the link (where the thumbnail seems to always work). 它背后的理论是no-referrer意味着图像请求与直接转到链接时使用的图像请求相同(缩略图似乎始终有效)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM