0

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

这是我正在使用的代码

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."
4

1 回答 1

0

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

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

于 2021-05-13T23:41:55.277 回答