桶操作¶
PUT Bucket¶
Creates a new bucket. To create a bucket, you must have a user ID and a valid AWS Access Key ID to authenticate requests. You may not create buckets as an anonymous user.
Note
We do not support request entities for PUT /{bucket}
in this release.
Constraints¶
In general, bucket names should follow domain name constraints.
Bucket names must be unique.
Bucket names must begin and end with a lowercase letter.
Bucket names may contain a dash (-).
语法¶
PUT /{bucket} HTTP/1.1
Host: cname.domain.com
x-amz-acl: public-read-write
Authorization: AWS {access-key}:{hash-of-header-and-secret}
参数¶
Name |
Description |
Valid Values |
Required |
---|---|---|---|
|
Canned ACLs. |
|
No |
HTTP 响应¶
If the bucket name is unique, within constraints and unused, the operation will succeed. If a bucket with the same name already exists and the user is the bucket owner, the operation will succeed. If the bucket name is already in use, the operation will fail.
HTTP Status |
Status Code |
Description |
---|---|---|
|
BucketAlreadyExists |
Bucket already exists under different user’s ownership. |
DELETE Bucket¶
Deletes a bucket. You can reuse bucket names following a successful bucket removal.
Syntax¶
DELETE /{bucket} HTTP/1.1
Host: cname.domain.com
Authorization: AWS {access-key}:{hash-of-header-and-secret}
HTTP Response¶
HTTP Status |
Status Code |
Description |
---|---|---|
|
No Content |
Bucket removed. |
GET Bucket¶
返回一系列桶对象。
语法¶
GET /{bucket}?max-keys=25 HTTP/1.1
Host: cname.domain.com
参数¶
Name |
Type |
Description |
---|---|---|
|
String |
Only returns objects that contain the specified prefix. |
|
String |
The delimiter between the prefix and the rest of the object name. |
|
String |
A beginning index for the list of objects returned. |
|
Integer |
The maximum number of keys to return. Default is 1000. |
|
Boolean |
Non-standard extension. Allows results to be returned unordered. Cannot be used with delimiter. |
HTTP Response¶
HTTP Status |
Status Code |
Description |
---|---|---|
|
OK |
Buckets retrieved |
Bucket Response Entities¶
GET /{bucket}
returns a container for buckets with the following fields.
Name |
Type |
Description |
---|---|---|
|
Entity |
The container for the list of objects. |
|
String |
The name of the bucket whose contents will be returned. |
|
String |
A prefix for the object keys. |
|
String |
A beginning index for the list of objects returned. |
|
Integer |
The maximum number of keys returned. |
|
String |
If set, objects with the same prefix will appear in the |
|
Boolean |
If |
|
Container |
If multiple objects contain the same prefix, they will appear in this list. |
Object Response Entities¶
The ListBucketResult
contains objects, where each object is within a Contents
container.
Name |
Type |
Description |
---|---|---|
|
Object |
A container for the object. |
|
String |
The object’s key. |
|
Date |
The object’s last-modified date/time. |
|
String |
An MD-5 hash of the object. (entity tag) |
|
Integer |
The object’s size. |
|
String |
Should always return |
Get Bucket Location¶
Retrieves the bucket’s region. The user needs to be the bucket owner
to call this. A bucket can be constrained to a region by providing
LocationConstraint
during a PUT request.
Syntax¶
Add the location
subresource to bucket resource as shown below
GET /{bucket}?location HTTP/1.1
Host: cname.domain.com
Authorization: AWS {access-key}:{hash-of-header-and-secret}
Response Entities¶
Name |
Type |
Description |
---|---|---|
|
String |
The region where bucket resides, empty string for defult region |
Get Bucket ACL¶
Retrieves the bucket access control list. The user needs to be the bucket
owner or to have been granted READ_ACP
permission on the bucket.
Syntax¶
Add the acl
subresource to the bucket request as shown below.
GET /{bucket}?acl HTTP/1.1
Host: cname.domain.com
Authorization: AWS {access-key}:{hash-of-header-and-secret}
Response Entities¶
Name |
Type |
Description |
---|---|---|
|
Container |
A container for the response. |
|
Container |
A container for the ACL information. |
|
Container |
A container for the bucket owner’s |
|
String |
The bucket owner’s ID. |
|
String |
The bucket owner’s display name. |
|
Container |
A container for |
|
Container |
A container for the |
|
String |
The permission given to the |
PUT Bucket ACL¶
Sets an access control to an existing bucket. The user needs to be the bucket
owner or to have been granted WRITE_ACP
permission on the bucket.
Request Entities¶
Name |
Type |
Description |
---|---|---|
|
Container |
A container for the request. |
|
Container |
A container for the ACL information. |
|
Container |
A container for the bucket owner’s |
|
String |
The bucket owner’s ID. |
|
String |
The bucket owner’s display name. |
|
Container |
A container for |
|
Container |
A container for the |
|
String |
The permission given to the |
List Bucket Multipart Uploads¶
GET /?uploads
returns a list of the current in-progress multipart uploads–i.e., the application initiates a multipart upload, but
the service hasn’t completed all the uploads yet.
Syntax¶
GET /{bucket}?uploads HTTP/1.1
Parameters¶
You may specify parameters for GET /{bucket}?uploads
, but none of them are required.
Name |
Type |
Description |
---|---|---|
|
String |
Returns in-progress uploads whose keys contains the specified prefix. |
|
String |
The delimiter between the prefix and the rest of the object name. |
|
String |
The beginning marker for the list of uploads. |
|
Integer |
The maximum number of in-progress uploads. The default is 1000. |
|
Integer |
The maximum number of multipart uploads. The range from 1-1000. The default is 1000. |
|
String |
Ignored if |
Response Entities¶
Name |
Type |
Description |
---|---|---|
|
Container |
A container for the results. |
|
String |
The prefix specified by the |
|
String |
The bucket that will receive the bucket contents. |
|
String |
The key marker specified by the |
|
String |
The marker specified by the |
|
String |
The key marker to use in a subsequent request if |
|
String |
The upload ID marker to use in a subsequent request if |
|
Integer |
The max uploads specified by the |
|
String |
If set, objects with the same prefix will appear in the |
|
Boolean |
If |
|
Container |
A container for |
|
String |
The key of the object once the multipart upload is complete. |
|
String |
The |
|
Container |
Contains the |
|
String |
The initiator’s display name. |
|
String |
The initiator’s ID. |
|
Container |
A container for the |
|
String |
The method used to store the resulting object. |
|
Date |
The date and time the user initiated the upload. |
|
Container |
If multiple objects contain the same prefix, they will appear in this list. |
|
String |
The substring of the key after the prefix as defined by the |
ENABLE/SUSPEND BUCKET VERSIONING¶
PUT /?versioning
这个子资源用于设置已有桶的版本化状态。只有桶所有者才能设置版本化状态。
版本化状态可以设置为如下取值之一:
Enabled : 为桶内的对象启用版本化支持,放入桶内的对象都会收到一个唯一的版本 ID 。
Suspended : 为桶内的对象禁用版本化支持,放入桶内的对象其版本 ID 都是 null 。
如果从没给某一个桶设置过版本化状态,那它就没有版本化状态; GET versioning 请求就不会返回版本化状态值。
语法¶
PUT /{bucket}?versioning HTTP/1.1
请求实体¶
名称 |
类型 |
描述 |
---|---|---|
|
Container |
用于包装此请求的容器。 |
|
String |
设置桶的版本化状态,可用值: Suspended/Enabled |