Bucket Operations¶
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.
Constraints¶
In general, bucket names should follow domain name constraints.
Bucket names must be unique.
Bucket names cannot be formatted as IP address.
Bucket names can be between 3 and 63 characters long.
Bucket names must not contain uppercase characters or underscores.
Bucket names must start with a lowercase letter or number.
Bucket names must be a series of one or more labels. Adjacent labels are separated by a single period (.). Bucket names can contain lowercase letters, numbers, and hyphens. Each label must start and end with a lowercase letter or a number.
Note
The above constraints are relaxed if the option ‘rgw_relaxed_s3_bucket_names’ is set to true except that the bucket names must still be unique, cannot be formatted as IP address and can contain letters, numbers, periods, dashes and underscores for up to 255 characters long.
Syntax¶
PUT /{bucket} HTTP/1.1
Host: cname.domain.com
x-amz-acl: public-read-write
Authorization: AWS {access-key}:{hash-of-header-and-secret}
Parameters¶
Name |
Description |
Valid Values |
Required |
|
---|---|---|---|---|
|
Canned ACLs. |
|
No |
|
|
Enable object lock on bucket. | |
No |
Request Entities¶
Name |
Type |
Description |
---|---|---|
|
Container |
A container for the bucket configuration. |
|
String |
A zonegroup api name, with optional S3 Bucket Placement |
HTTP Response¶
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¶
Returns a list of bucket objects.
Syntax¶
GET /{bucket}?max-keys=25 HTTP/1.1
Host: cname.domain.com
Parameters¶
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 |
|
String |
|
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 default 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
This subresource set the versioning state of an existing bucket. To set the versioning state, you must be the bucket owner.
You can set the versioning state with one of the following values:
Enabled : Enables versioning for the objects in the bucket, All objects added to the bucket receive a unique version ID.
Suspended : Disables versioning for the objects in the bucket, All objects added to the bucket receive the version ID null.
If the versioning state has never been set on a bucket, it has no versioning state; a GET versioning request does not return a versioning state value.
Syntax¶
PUT /{bucket}?versioning HTTP/1.1
REQUEST ENTITIES¶
Name |
Type |
Description |
---|---|---|
|
Container |
A container for the request. |
|
String |
Sets the versioning state of the bucket. Valid Values: Suspended/Enabled |
PUT BUCKET OBJECT LOCK¶
Places an Object Lock configuration on the specified bucket. The rule specified in the Object Lock configuration will be applied by default to every new object placed in the specified bucket.
Syntax¶
PUT /{bucket}?object-lock HTTP/1.1
Request Entities¶
Name |
Type |
Description |
Required |
---|---|---|---|
|
Container |
A container for the request. |
Yes |
|
String |
Indicates whether this bucket has an Object Lock configuration enabled. |
Yes |
|
Container |
The Object Lock rule in place for the specified bucket. |
No |
|
Container |
The default retention period applied to new objects placed in the specified bucket. |
No |
|
String |
The default Object Lock retention mode. Valid Values: GOVERNANCE/COMPLIANCE |
Yes |
|
Integer |
The number of days specified for the default retention period. |
No |
|
Integer |
The number of years specified for the default retention period. |
No |
HTTP Response¶
If the bucket object lock is not enabled when creating the bucket, the operation will fail.
HTTP Status |
Status Code |
Description |
---|---|---|
|
MalformedXML |
The XML is not well-formed |
|
InvalidBucketState |
The bucket object lock is not enabled |
GET BUCKET OBJECT LOCK¶
Gets the Object Lock configuration for a bucket. The rule specified in the Object Lock configuration will be applied by default to every new object placed in the specified bucket.
Syntax¶
GET /{bucket}?object-lock HTTP/1.1
Response Entities¶
Name |
Type |
Description |
Required |
---|---|---|---|
|
Container |
A container for the request. |
Yes |
|
String |
Indicates whether this bucket has an Object Lock configuration enabled. |
Yes |
|
Container |
The Object Lock rule in place for the specified bucket. |
No |
|
Container |
The default retention period applied to new objects placed in the specified bucket. |
No |
|
String |
The default Object Lock retention mode. Valid Values: GOVERNANCE/COMPLIANCE |
Yes |
|
Integer |
The number of days specified for the default retention period. |
No |
|
Integer |
The number of years specified for the default retention period. |
No |
Create Notification¶
Create a publisher for a specific bucket into a topic.
Syntax¶
PUT /<bucket name>?notification HTTP/1.1
Request Entities¶
Parameters are XML encoded in the body of the request, in the following format:
<NotificationConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<TopicConfiguration>
<Id></Id>
<Topic></Topic>
<Event></Event>
<Filter>
<S3Key>
<FilterRule>
<Name></Name>
<Value></Value>
</FilterRule>
</S3Key>
<S3Metadata>
<FilterRule>
<Name></Name>
<Value></Value>
</FilterRule>
</s3Metadata>
</Filter>
</TopicConfiguration>
</NotificationConfiguration>
Name |
Type |
Description |
Required |
---|---|---|---|
|
Container |
Holding list of |
Yes |
|
Container |
Holding |
Yes |
|
String |
Name of the notification |
Yes |
|
String |
Topic ARN. Topic must be created beforehand |
Yes |
|
String |
List of supported events see: S3 Notification Compatibility. Multiple |
No |
|
Container |
Holding |
No |
|
Container |
Holding a list of |
No |
|
Container |
Holding a list of |
No |
|
Container |
Holding |
Yes |
|
Container |
Holding |
Yes |
HTTP Response¶
HTTP Status |
Status Code |
Description |
---|---|---|
|
MalformedXML |
The XML is not well-formed |
|
InvalidArgument |
Missing Id; Missing/Invalid Topic ARN; Invalid Event |
|
NoSuchBucket |
The bucket does not exist |
|
NoSuchKey |
The topic does not exist |
Delete Notification¶
Delete a specific, or all, notifications from a bucket.
Note
Notification deletion is an extension to the S3 notification API
When the bucket is deleted, any notification defined on it is also deleted
Deleting an unknown notification (e.g. double delete) is not considered an error
Syntax¶
DELETE /bucket?notification[=<notification-id>] HTTP/1.1
Parameters¶
Name |
Type |
Description |
---|---|---|
|
String |
Name of the notification. If not provided, all notifications on the bucket are deleted |
HTTP Response¶
HTTP Status |
Status Code |
Description |
---|---|---|
|
NoSuchBucket |
The bucket does not exist |
Get/List Notification¶
Get a specific notification, or list all notifications configured on a bucket.
Syntax¶
GET /bucket?notification[=<notification-id>] HTTP/1.1
Parameters¶
Name |
Type |
Description |
---|---|---|
|
String |
Name of the notification. If not provided, all notifications on the bucket are listed |
Response Entities¶
Response is XML encoded in the body of the request, in the following format:
<NotificationConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<TopicConfiguration>
<Id></Id>
<Topic></Topic>
<Event></Event>
<Filter>
<S3Key>
<FilterRule>
<Name></Name>
<Value></Value>
</FilterRule>
</S3Key>
<S3Metadata>
<FilterRule>
<Name></Name>
<Value></Value>
</FilterRule>
</s3Metadata>
</Filter>
</TopicConfiguration>
</NotificationConfiguration>
Name |
Type |
Description |
Required |
---|---|---|---|
|
Container |
Holding list of |
Yes |
|
Container |
Holding |
Yes |
|
String |
Name of the notification |
Yes |
|
String |
Topic ARN |
Yes |
|
String |
Handled event. Multiple |
Yes |
|
Container |
Holding the filters configured for this notification |
No |
HTTP Response¶
HTTP Status |
Status Code |
Description |
---|---|---|
|
NoSuchBucket |
The bucket does not exist |
|
NoSuchKey |
The notification does not exist (if provided) |