为什么我用s3和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'
答案 0 :(得分:6)
BucketAlreadyOwnedByYou
错误只会在美国标准区域之外返回。在美国标准区域内(即,当您未指定位置约束时),尝试重新创建您已拥有的存储桶将成功。
<强>来源 http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html
答案 1 :(得分:2)
显然,具有相同名称的容器已经存在。
答案 2 :(得分:1)
由于你已经有了一个存储桶,你可以删除最后三行代码并用以下代码替换它们:
bucket = conn.get_bucket(bucket, validate = False)
k = Key(bucket)
k.key = key