CORS setting on google cloud bucket

末鹿安然 提交于 2020-01-02 07:04:14

问题


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?


回答1:


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
  }
]


来源:https://stackoverflow.com/questions/43109327/cors-setting-on-google-cloud-bucket

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!