【发布时间】:2017-09-05 23:03:15
【问题描述】:
我正在尝试在谷歌存储桶上设置 CORS 配置。我指的是https://cloud.google.com/storage/docs/xml-api/put-bucket-cors。有人可以帮助我如何在 python 中使用这个请求。
【问题讨论】:
标签: python cors google-cloud-platform google-cloud-storage
我正在尝试在谷歌存储桶上设置 CORS 配置。我指的是https://cloud.google.com/storage/docs/xml-api/put-bucket-cors。有人可以帮助我如何在 python 中使用这个请求。
【问题讨论】:
标签: python cors google-cloud-platform google-cloud-storage
您可能希望改用 JSON API,并使用 google-cloud-storage 库。 Bucket 的文档是here。
我还没有尝试过,但是类似:
from google.cloud import storage
bucket = storage.Client().get_bucket('bucket-id-here')
bucket.cors = [{
origin: ['*', ...],
method: ['GET', ...],
responseHeader: ['some-resp-header', ...],
maxAgeSeconds: 86400, # one day
}]
bucket.patch() # Send the update
【讨论】: