Google Cloud Platform Storage error: "Locked Domain Expired" when trying to access my storage items

Google Cloud Platform Storage error: "Locked Domain Expired" when trying to access my storage items

我目前在 google 云平台存储桶中为我的站点托管一些静态 .css、.js、.tff 和图像资源。上传这些资源后,我最多可以访问这些资源大约 20 分钟。大约 20 分钟后,当我尝试访问它们时收到 401 错误消息:

{"error":{"errors":[{"domain":"global","reason":"lockedDomainExpired","message":"Locked Domain Expired"}],"code":401,"message":"Locked Domain Expired"}}

来自 GCP 站点:

lockedDomainExpired: When downloading content from a cookie-authenticated site, e.g., using the Storage Browser, the response will redirect to a temporary domain. This error will occur if access to said domain occurs after the domain expires. Issue the original request again, and receive a new redirect.

我不太确定这在我尝试使用 GCP 存储桶的上下文中意味着什么?任何帮助或资源将不胜感激。

当您在开发者控制台中点击某个对象的 link 时,它会生成一个仅在短时间内有效的 URL。我怀疑您是将此 URL 复制到您的网站,而不是使用可公开访问的 URL.

假设对象是公开可读的,您应该可以使用这种 URL 格式。

https://storage.googleapis.com/<bucket>/<object>

通过打开对象的link并快速select打开的选项卡,如果我们截屏或select选项卡,您可以看到真正的url的对象,也就是我们要找的对象。

https://storage.googleapis.com/<segment>/<path-file>/<file>

其中:

  • <segment>是段名
  • <path file>是段内文件的路径
  • <file> es el nombre del archivo con la extensión incluida

请注意,屏幕是在页面完成加载并生成临时 url 之前截取的。然而,基础 URL 不适用于 Web 服务,因此我们必须使用 storage.googleapis.com 而不是使用 storage.cloud.google.com y checkear que en la pestaña de la URL 云存储图标 (esto nos dará un indicio que la url nos funcionará)

在这里你可以看到路径和文件的层次结构

文件扩展名后面的字符可以忽略

不要忘记激活 public link 检查您是否正在使用 Web 服务