Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

connect to bucket having uppercase letter

Tags:

boto

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.
like image 799
shantanuo Avatar asked Sep 30 '13 07:09

shantanuo


2 Answers

S3 recommend that you only use DNS-compliant bucket names.

Take a look at the restrictions page: http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html

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')
like image 128
shry Avatar answered Sep 28 '22 11:09

shry


To addings those lines to .boto file are worked for me

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

Referance

like image 33
itirazimvar Avatar answered Sep 28 '22 12:09

itirazimvar