2017-04-10 46 views

回答

3

您可能想使用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 
+0

我试过上述建议,但它不更新对存储桶。你能帮我提供一些额外的信息吗? – user3571631

+0

可能需要在存储桶上调用[patch](https://googlecloudplatform.github.io/google-cloud-python/stable/storage-buckets.html#google.cloud.storage.bucket.Bucket.patch)发送更新。 –

+0

欢呼声,它的作品 – user3571631