谷歌云桶上的CORS设置

时间:2017-03-30 05:33:32

标签: cors google-cloud-platform

我正在尝试在google bucket上配置CORS。我想在每次创建新存储桶时设置CORS配置。我希望云存储客户端库完成此操作,而不是使用XML API。有办法吗?

1 个答案:

答案 0 :(得分:4)

任何语言中的Cloud Storage Client Libraries似乎都没有提供直接设置CORS配置的能力。因此,似乎唯一的选择是使用the XML API with the cors param或者从命令行using gsutil and a JSON config file执行此操作,如下所示:

gsutil cors set cors-json-file.json gs://[my-bucket]

其中cors-json-file.json是这样的:

[
  {
    "origin": ["*"],
    "responseHeader": ["Content-Type"],
    "method": ["GET"],
    "maxAgeSeconds": 3600
  }
]