简体   繁体   English

无法使用 python 在 IBM Cloud object 存储中检索存储桶名称

[英]Cannot retrieve bucket name in IBM Cloud object storage using python

While retrieving the bucket name, it shows me this error.在检索存储桶名称时,它向我显示此错误。

CLIENT ERROR: An error occurred (InvalidArgument) when calling the ListBuckets operation: Invalid Argument

And another thing I want to know that COS_ENDPOINT is correct or not.还有一件事我想知道 COS_ENDPOINT 是否正确。 Because it's also showing me the XML formatting error while retrieving.因为它还在检索时向我显示 XML 格式错误。 Here is the code:这是代码:

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()

Please help me out.请帮帮我。

Thanks in advance.提前致谢。

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 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
COS_AUTH_ENDPOINT = "https://iam.bluemix.net/oidc/token"
SERVICE_INSTANCE_ID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

"resource_instance_id": "crn:v1:bluemix:public:cloud-object-storage:global:a/3c467ce9e6d84b90065fd00be3065964:65c5b3g2-7db5-4251-93a1-a7c33486d5e9::" “resource_instance_id”:“crn:v1:bluemix:public:cloud-object-storage:global:a/3c467ce9e6d84b90065fd00be3065964:65c5b3g2-7db5-4251-93a1-a7c33486d5e9::”

In Service instance ID use: 65c5b3g2-7db5-4251-93a1-a7c33486d5e9 ( This is not my resource_instance_id )在服务实例 ID 中使用:65c5b3g2-7db5-4251-93a1-a7c33486d5e9(这不是我的 resource_instance_id

# 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
)

for bucket in cos.buckets.all():
    print(bucket.name)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试使用 Python 列出 IBM Cloud Object Storage 中的对象时“指定的存储桶不存在” - "The specified bucket does not exist" when trying to list objects in IBM Cloud Object Storage using Python 使用 python 将文件上传到 IBM 云 object 存储时出错 - error while uploading file to IBM cloud object storage using python 如何从存储桶中获取所有文件 - IBM Cloud Object Storage? - How to get all files from a Bucket - IBM Cloud Object Storage? 使用Python API客户端在GCS上检索gs://的存储桶和对象的路径 - Retrieve gs:// path for a storage Bucket and Object at GCS using Python api client 使用Python的IBM对象存储 - IBM Object Storage with Python IBM Cloud Object 存储连接问题 Watson studio Python 笔记本 - IBM Cloud Object Storage Connection issue Watson studio Python notebook 如何使用 Python 为 Google Cloud Storage Bucket 应用正则表达式 - How to apply regex for Google Cloud Storage Bucket using Python 有没有办法使用 python 获取谷歌云存储桶中的对象数量? - Is there a way to get number of objects in a google cloud storage bucket using python? 使用 Python 将文件上传到 Google Cloud Storage Bucket 子目录 - Upload File to Google Cloud Storage Bucket Sub Directory using Python 使用python从谷歌云存储桶下载整个目录 - Download entire directories from google cloud storage bucket using python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM