云存储CORS [英] cloud storage CORS

查看:91
本文介绍了云存储CORS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Google Earth Engine中的地图导出到具有公共访问权限(allUsers)的云存储桶中。存储桶中的格式是带有.png扩展名的地图图块。

I've exported a map from Google Earth Engine into a cloud storage bucket with public access (allUsers). The format in the bucket is map tiles with .png extensions.

我还使用gsutil设置了我的CORS设置,如下所示:

I've also set my CORS settings with gsutil as follows:

[
    {
      "origin": ["*"],
      "responseHeader": ["Authorization", "Content-Range", "Accept", "Content-Type", "Origin", "Range"],
      "method": ["GET"],
      "maxAgeSeconds": 300
    }
]

但尝试访问这些地图图块(带有Leaflet tileLayer的图层)我在Chrome开发人员工具中收到了CORB(跨原点读取阻止)错误,但没有任何显示。

But trying to access these map tiles (with a Leaflet tileLayer) I get CORB (cross origin read blocking) errors in Chrome developer tools and nothing shows.

我在Chrome DT中的响应标头显示以下内容:

My response headers in Chrome DT show these:

cache-control: no-cache, no-store, max-age=0, must-revalidate
content-type: text/html; charset=utf-8
expires: Mon, 01 Jan 1990 00:00:00 GMT

我该如何解决这个问题?

How can I resolve this issue?

推荐答案

如果您想使所有存储桶公开可见,则需要提供 IAM政策只需运行:

If you want to make all you bucket public readable, you need to provide IAM policies just run:

gsutil iam ch allUsers:objectViewer gs://youBucketName

更新:
您必须使用的要点是:

Update: The enpoint you must use is:

"https://storage.googleapis.com/bucketName/ObjectName"

来自文档


对存储的所有请求.cloud.google.com URI要求身份验证。即使allUsers有权访问对象,这也适用。如果希望用户下载未经身份验证的匿名对象而不进行身份验证,请使用Direct API请求中记录的storage.googleapis.com URI。有关详细信息和示例,请参阅访问公共数据。

All requests to the storage.cloud.google.com URI require authentication. This applies even when allUsers have permission to access an object. If you want users to download anonymously accessible objects without authenticating, use the storage.googleapis.com URI documented in Direct API requests. For details and examples, see Accessing Public Data.

您正在直接使用 https://console.cloud .google.com / storage ,这就是为什么您会遇到此错误的原因

You are using directly https://console.cloud.google.com/storage and that's why you will encounter this errors

示例:

您有:
https: //console.cloud.google.com/storage/browser/logs1tiles/centralKansas/8/58/99

应为:
https://storage.googleapis.com/logs1tiles/centralKansas/8/58/ 99

这篇关于云存储CORS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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