我想使用 python 客户端在位于欧洲的 GCS 中创建一个存储桶。
from google.cloud import storage
实例化一个客户端
storage_client = storage.Client()
新桶的名称
bucket_name = 'my-new-bucket'
创建新的桶
bucket = storage_client.create_bucket(bucket_name)
print('Bucket {} created.'.format(bucket.name))
这会在美国创建多区域存储桶。如何将其更改为欧洲?
最佳答案
create_bucket
方法是有限制的。对于更多参数,您将创建一个存储桶资源并调用其 create()
方法,如下所示:
storage_client = storage.Client()
bucket = storage_client.bucket('bucket-name')
bucket.create(location='EU')
Bucket.create 还有一些其他属性并记录在案:https://googleapis.github.io/google-cloud-python/latest/storage/buckets.html#google.cloud.storage.bucket.Bucket.create
关于google-cloud-storage - 在自定义位置的 Google Cloud Storage 中创建存储桶,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54992263/