gpt4 book ai didi

boto - 连接到具有大写字母的存储桶

转载 作者:行者123 更新时间:2023-12-04 13:01:10 26 4
gpt4 key购买 nike

如果存储桶名称有大写字母,我将无法连接到存储桶。
我有几个桶,里面有大写字母。

>>> mybucket = conn.get_bucket('Vig_import')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/boto/s3/connection.py", line 391, in get_bucket
bucket.get_all_keys(headers, maxkeys=0)
File "/usr/lib/python2.6/site-packages/boto/s3/bucket.py", line 360, in get_all_keys
'', headers, **params)
File "/usr/lib/python2.6/site-packages/boto/s3/bucket.py", line 317, in _get_all
query_args=s)
File "/usr/lib/python2.6/site-packages/boto/s3/connection.py", line 462, in make_request
host = self.calling_format.build_host(self.server_name(), bucket)
File "/usr/lib/python2.6/site-packages/boto/s3/connection.py", line 86, in build_host
return self.get_bucket_server(server, bucket)
File "/usr/lib/python2.6/site-packages/boto/s3/connection.py", line 65, in wrapper
if len(args) == 3 and check_lowercase_bucketname(args[2]):
File "/usr/lib/python2.6/site-packages/boto/s3/connection.py", line 57, in check_lowercase_bucketname
raise BotoClientError("Bucket names cannot contain upper-case " \
boto.exception.BotoClientError: BotoClientError: Bucket names cannot contain upper-case characters when using either the sub-domain or virtual hosting calling format.

最佳答案

S3 建议您仅使用符合 DNS 的存储桶名称。

看一下限制页面:http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html

无论您如何操作,在 boto 中,您都可以对具有大小写混合名称的存储桶使用不同的调用格式:

from boto.s3.connection import OrdinaryCallingFormat

conn = boto.connect_s3(calling_format=OrdinaryCallingFormat())
mybucket = conn.get_bucket('Vig_import')

关于boto - 连接到具有大写字母的存储桶,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19088584/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com