Boto s3 error. BucketAlreadyOwnedByYou

瘦欲@ 提交于 2019-12-09 03:39:15

问题


Why do I get this error with s3 and boto?

<Error><Code>BucketAlreadyOwnedByYou</Code><Message>Your previous request to create the named bucket succeeded and you already own it.</Message><BucketName>rtbhui</BucketName><RequestId>84115D3E9513F3C9</RequestId><HostId>+3TxrA34xHcSx0ecOD3pseRnE+LwUv3Ax1Pvp3PFoE8tHfOcn5BXyihc9V/oJx2g</HostId></Error>

s3 = boto.connect_s3(parms['AWS_ACCESS_KEY_ID'], parms['AWS_SECRET_ACCESS_KEY'])
bucket = s3.create_bucket(bucket_name)
k = Key(bucket) #bucket is global
k.key = bucket_path_and_key #'test/test/test'

回答1:


BucketAlreadyOwnedByYou errors will only be returned outside of the US Standard region. Inside the US Standard region (i.e. when you don't specify a location constraint), attempting to recreate a bucket you already own will succeed.

Source http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html




回答2:


Obviously, container with same name is already exist.




回答3:


Since you already have a bucket you can just delete the last three lines of code and replace them with something like:

bucket = conn.get_bucket(bucket, validate = False)
k = Key(bucket)
k.key = key


来源:https://stackoverflow.com/questions/10346378/boto-s3-error-bucketalreadyownedbyyou

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!