google-cloud-storage - 在自定义位置的 Google Cloud Storage 中创建存储桶

标签 google-cloud-storage google-cloud-python

我想使用 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/

相关文章:

python - GCS 中未删除空 'folder'

python - 导入和初始化 GCP googleapis/google-cloud-python 客户端

python - 使用Python SDK时如何防止GCS自动解压对象?

python - firebase tic-tac-toe 示例中如何使用 ndb(和云数据存储)

python - 使用python在谷歌云存储桶中创建文件夹

php - 没有缓存的谷歌云存储公共(public)访问

java - 向 Google Cloud Storage API 提供凭据

node.js - 如何使用node.js在firebase中存储文件

kubernetes - 如何处理已发布的持久卷?

google-cloud-python - 增加连接池大小