在自定义位置的 Google Cloud Storage 中创建存储桶
Creating bucket in Google Cloud Storage in custom location
我想使用 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
你可以试试这个:
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))
我想使用 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
你可以试试这个:
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))