繁体   English   中英

在Amazon AWS中使用python中的boto创建S3存储桶失败…

[英]Creating a S3 bucket in Amazon AWS with boto in python fails …

import boto
import boto.s3
import boto.s3.connection

conn = boto.s3.connect_to_region(
'us-west-2', 
aws_access_key_id='MY_KEY', 
aws_secret_access_key='MY_ACCESS_KEY'
)

conn.create_bucket('bucket_in_west')

我得到这个错误:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/user/.virtualenvs/west-tests/lib/python2.7/site-packages/boto/s3/connection.py", line 621, in create_bucket
    response.status, response.reason, body)
S3ResponseError: S3ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>IllegalLocationConstraintException</Code><Message>The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.</Message><RequestId>0C0F09FBC87

是否有人对如何使用Boto在特定区域创建S3存储桶有答案?

如果您正在与us-west-2端点通信,并且想要在该区域中创建存储桶,则在调用create_bucket时必须指定该存储桶:

conn.create_bucket('bucket-in-west', location='us-west-2')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM