检索存储桶名称时,它向我显示此错误。
CLIENT ERROR: An error occurred (InvalidArgument) when calling the ListBuckets operation: Invalid Argument
还有一件事我想知道 COS_ENDPOINT 是否正确。因为它还在检索时向我显示了 XML 格式错误。这是代码:
import ibm_boto3
from ibm_botocore.client import Config, ClientError
# Constants for IBM COS values
COS_ENDPOINT = "https://s3.eu-gb.cloud-object-storage.appdomain.cloud"
COS_API_KEY_ID = "xxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
COS_AUTH_ENDPOINT = "https://iam.bluemix.net/oidc/token"
SERVICE_INSTANCE_ID = "crn:v1:bluemix:public:iam-identity::a/xxxxxxxxxxxxxxxxxxx::serviceid:ServiceId-xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"
# Create resource
cos = ibm_boto3.resource("s3",
ibm_api_key_id=COS_API_KEY_ID,
ibm_service_instance_id=SERVICE_INSTANCE_ID,
ibm_auth_endpoint=COS_AUTH_ENDPOINT,
config=Config(signature_version="oauth"),
endpoint_url=COS_ENDPOINT
)
def get_buckets():
print("Retrieving list of buckets")
try:
buckets = cos.buckets.all()
for bucket in buckets:
print("Bucket Name: {0}".format(bucket.name))
except ClientError as be:
print("CLIENT ERROR: {0}\n".format(be))
except Exception as e:
print("Unable to retrieve list buckets: {0}".format(e))
get_buckets()
请帮帮我。
提前致谢。