我想使用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))
这将在美国创建存储分区。如何将其更改为欧洲?
答案 0 :(得分:2)
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
答案 1 :(得分:0)
您可以尝试以下操作:
def create_bucket(bucket_name):
storage_client = storage.Client()
bucket = storage_client.create_bucket(bucket_name, location='EUROPE-WEST1')
print("Bucket {} created".format(bucket.name))