如何使用 python SDK 创建存储桶?
How to create a bucket using the python SDK?
我正在尝试使用 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."
前往 https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-endpoints#endpoints
解决
并选择特定于我需要的区域的端点。凭据提供的“端点”不是实际的端点。
我正在尝试使用 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."
前往 https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-endpoints#endpoints
解决并选择特定于我需要的区域的端点。凭据提供的“端点”不是实际的端点。