【问题标题】:How to create a bucket using the python SDK?如何使用 python SDK 创建存储桶?
【发布时间】:2021-08-04 05:03:08
【问题描述】:

我正在尝试使用 python 在云对象存储中创建一个存储桶。我已按照API docs 中的说明进行操作。

这是我正在使用的代码

COS_ENDPOINT = "https://control.cloud-object-storage.cloud.ibm.com/v2/endpoints"

# Create client 
cos = ibm_boto3.client("s3",
    ibm_api_key_id=COS_API_KEY_ID,
    ibm_service_instance_id=COS_INSTANCE_CRN,
    config=Config(signature_version="oauth"),
    endpoint_url=COS_ENDPOINT
)
s3 = ibm_boto3.resource('s3') 

def create_bucket(bucket_name):
    print("Creating new bucket: {0}".format(bucket_name))
    s3.Bucket(bucket_name).create()
    return
        
bucket_name = 'test_bucket_442332'
create_bucket(bucket_name)

我收到此错误 - 我尝试设置 CreateBucketConfiguration={"LocationConstraint":"us-south"},但它似乎不起作用

"ClientError: An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to."

【问题讨论】:

    标签: ibm-cloud ibm-cloud-storage


    【解决方案1】:

    转至https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-endpoints#endpoints解决

    并选择特定于我需要的区域的端点。凭据提供的“端点”不是实际的端点。

    【讨论】:

      猜你喜欢
      • 2017-12-25
      • 2020-10-14
      • 1970-01-01
      • 1970-01-01
      • 2015-09-14
      • 2021-07-13
      • 1970-01-01
      • 1970-01-01
      • 2015-04-05
      相关资源
      最近更新 更多