2
我想在谷歌存储桶上设置CORS配置。我指的是https://cloud.google.com/storage/docs/xml-api/put-bucket-cors。有人可以帮助我如何在python中使用这个请求。在谷歌桶上的CORS配置
我想在谷歌存储桶上设置CORS配置。我指的是https://cloud.google.com/storage/docs/xml-api/put-bucket-cors。有人可以帮助我如何在python中使用这个请求。在谷歌桶上的CORS配置
您可能想使用JSON API,并使用google-cloud-storage库。文件桶是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
我试过上述建议,但它不更新对存储桶。你能帮我提供一些额外的信息吗? – user3571631
可能需要在存储桶上调用[patch](https://googlecloudplatform.github.io/google-cloud-python/stable/storage-buckets.html#google.cloud.storage.bucket.Bucket.patch)发送更新。 –
欢呼声,它的作品 – user3571631