如何通过Postman在AWS S3中创建存储桶

时间:2016-10-19 12:59:42

标签: amazon-web-services amazon-s3 postman

我使用Postman AWS Signature连接S3服务,我可以获得桶中的所有存储桶,文件夹,也可以删除存储桶。

以下是我可以通过Postman进行的请求列表。

List of all bucket inside the specific region: GET    https://s3-us-west-2.amazonaws.com/
List of all objects/folders inside the bucket: GET    https://s3-us-west-2.amazonaws.com/<bucket name>
Delete the bucket/file (when it's empty):      DELETE https://s3-us-west-2.amazonaws.com/<bucket name>/[<file name>]
Create the file into the bucket:               PUT    https://s3-us-west-2.amazonaws.com/<bucket name>/[<file name>][<folder name>/]

当我想创建一个桶(PUT方法)时,它会回复我一条错误信息。

The unspecified location constraint is incompatible for the region specific endpoint this request was sent to

所以问题。如何通过Postman创建桶?提前谢谢。

1 个答案:

答案 0 :(得分:0)

AWS通过API调用创建存储桶的文档提到您可以在请求正文中提供位置约束:

<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> 
    <LocationConstraint>YourBucketRegion</LocationConstraint> 
</CreateBucketConfiguration>

尝试将其添加到您选择的区域:

Valid Values: [ us-west-1 | us-west-2 | EU or eu-west-1 | 
eu-central-1 | ap-south-1 | ap-southeast-1 | ap-southeast-2 | 
ap-northeast-1 | ap-northeast-2 | sa-east-1 | us-east-2]

以下是完整语法:

PUT / HTTP/1.1
Host: BucketName.s3.amazonaws.com
Content-Length: length
Date: date
Authorization: authorization string (see Authenticating Requests (AWS Signature Version
    4))

<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> 
<LocationConstraint>BucketRegion</LocationConstraint> 
</CreateBucketConfiguration>

来源:AWS Docs