谷歌云存储桶上的CORS设置 [英] CORS setting on google cloud bucket

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

问题描述

我正尝试在谷歌存储桶上配置CORS。每次创建新存储桶时,我都想设置CORS配置。我想通过云存储客户端库完成此操作,而不是使用XML API。解决方案

storage / docs / reference / libraries任何语言的云存储客户端库都可以直接设置CORS配置。因此,似乎唯一的选择是使用 XML API cors param ,或者从命令行使用 gsutil 和一个JSON配置文件,如下所示:

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

其中 cors-json-file.json 就像这样:

  [
{
origin:[*],
responseHeader:[Content 类型],
方法:[GET],
maxAgeSeconds:3600
}
]


I am trying to configure CORS on a google bucket.I want to set CORS config every time i create a new bucket. I want to get this done by Cloud Storage Client Libraries, not using XML API. Is there a way around it?

解决方案

None of the Cloud Storage Client Libraries in any language appear to provide the ability to directly set the CORS config. So it seems the only options are either to use the XML API with the cors param or else to do it from the command line using gsutil and a JSON config file, like this:

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

Where cors-json-file.json is something like this:

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

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

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