gcloud - 创建 glcoud 存储桶时无法指定存储桶的位置
问题描述
我认为以下代码将在美国西部地区构建一个存储桶,但在我的谷歌控制台上,该地区被列为多地区。
from google.cloud import storage
storage_client = storage.Client()
bucket = storage_client.create_bucket(bucket_name)
bucket.location = 'us-west2-a'
解决方案
from google.cloud import storage
storage_client = storage.Client()
bucket = storage_client.create_bucket(bucket_name)
bucket.location = 'us-west2-a'
您的代码示例中的问题是您指定了区域名称“us-west2-a”,而不是区域(位置)名称“us-west2”。
from google.cloud import storage
storage_client = storage.Client()
bucket = storage_client.create_bucket(bucket_name)
bucket.location = 'us-west2'
通过更改为“us-west2”,它应该在所需位置创建您的存储桶。
参考:
推荐阅读
- html - 如何将背景图像应用到卡片上,使其被部分裁剪?
- asp.net-core - 在 .netcore3.1 的库输出类型中添加带有 nuget 的 dll 时构建 dll 失败
- c++ - main.c:12:25:警告:格式“%ld”需要“long int”类型的参数,
- php - 为什么 PHP 8 将 42 == " 42" 视为真?
- reactjs - 使用 FBX 加载器更改 React 三纤维中的材料
- javascript - Dart 基数排序实现
- rider - 在 JetBrains Rider 中,有没有办法在不关闭正在运行的项目的情况下运行复合运行/调试配置?
- qt - QML中Window和ApplicationWindow的区别?
- c++ - 带字符串的 C++ 构造函数
- azure - 如何在 ServiceBus ManagementClient CreateSubscriptionAsync 上设置 TTL