本文介绍了连接到具有大写字母的存储桶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果存储桶名称包含大写字母,则无法连接到存储桶.我有几个带有大写字母的水桶.
I am not able to connect to a bucket if the bucket name has a Upper case letter.I have several buckets those has capital letter in it.
>>> 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的存储桶名称.
S3 recommend that you only use DNS-compliant bucket names.
看看限制页面: http://docs. aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
无论如何,您都可以在boto中为大小写混合的存储桶使用其他调用格式:
However you do it, in boto you can use a different calling format for buckets with a mixed-case name:
from boto.s3.connection import OrdinaryCallingFormat
conn = boto.connect_s3(calling_format=OrdinaryCallingFormat())
mybucket = conn.get_bucket('Vig_import')
这篇关于连接到具有大写字母的存储桶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!