Errno 11004 getaddrinfo failed 错误连接到 Amazon S3 存储桶

Errno 11004 getaddrinfo failed error in connecting to Amazon S3 bucket

我正在尝试使用 Python 中的 boto (ver 2.43.0) 库连接到 S3,但是当我尝试时,我一直收到 `socket.gaierror: [Errno 11004]要做到这一点:

from boto.s3.connection import S3Connection

access_key = 'accesskey_here'
secret_key = 'secretkey_here'
conn = S3Connection(access_key, secret_key)
mybucket = conn.get_bucket('s3://diap.prod.us-east-1.mybucket/')
print("success!")

我可以使用 AWS CLI 连接和访问 mybucket 中的文件夹,方法是在 Windows 中使用这样的命令:

> aws s3 ls s3://diap.prod.us-east-1.mybucket/
<list of folders in mybucket will be here>

或使用 CloudBerry 或 S3Browser 等软件。

为了正确访问 S3 存储桶和文件夹,我在这里做错了什么吗?在此先感谢您的回答!

get_bucket() 需要存储桶名称。

get_bucket(bucket_name, validate=True, headers=None)

尝试:

mybucket = conn.get_bucket('mybucket')

如果它不起作用,请显示完整的堆栈跟踪。

{更新]:boto 库中存在带点的存储桶名称错误。更新您的 boto 配置

[s3]
calling_format = boto.s3.connection.OrdinaryCallingFormat

from boto.s3.connection import S3Connection, OrdinaryCallingFormat

conn = S3Connection(access_key, secret_key, calling_format=OrdinaryCallingFormat())