Add and delete a Bucket in IBM COS (S3)

Using buckets via the Bluemix Portal

  1. Click the Account Name in the above accounts list to open the details page for that account.
  2. The details page shows the following info on the top header bar:
    • Name of the account currently being viewed
    • The current region being viewed
    • The total capacity usage in the current billing cycle
    • The total bandwidth usage in the current billing cycle
  3. The page also shows the list of buckets present in the account.
  4. A new bucket can be added by clicking on the + button at the right of the first row.
  5. The new bucket name can be entered and the new bucket added, by clicking the Add button. Bucket names must be DNS-compliant. Names must be between 3 and 63 characters long, must be made of lowercase letters, numbers, and dashes, must be globally unique, and cannot appear to be an IP address. A common approach to ensuring uniqueness is to append a UUID or other distinctive suffix to bucket names.
  6. A bucket can be deleted, by clicking the red - button to the extreme right of the bucket name. This opens a confirmation window.
    • Note: Only empty buckets can be deleted. Attempting to delete a non-empty bucket will result in an error.
  7. Click the Delete button to remove the bucket from the account.

Using buckets from SoftLayer Portal

  1. Login to control
  2. Click the Storage tab and then Object Storage
  3. Click the Object storage account you wish to use
  4. The details page shows the following info on the top header bar:
    • Name of the account currently being viewed
    • The total capacity usage in the current billing cycle
    • The total bandwidth usage in the current billing cycle
  5. The page also shows the list of buckets present in the account.
  6. A new bucket can be added by clicking on the + button at the right of the first row.
  7. The new bucket name can be entered and the new bucket added, by clicking the Add button. Bucket names must be DNS-compliant. Names must be between 3 and 63 characters long, must be made of lowercase letters, numbers, and dashes, must be globally unique, and cannot appear to be an IP address. A common approach to ensuring uniqueness is to append a UUID or other distinctive suffix to bucket names.
  8. A bucket can be deleted, by clicking the red - button to the extreme right of the bucket name. This opens a confirmation window.
    • Note: Only empty buckets can be deleted. Attempting to delete a non-empty bucket will result in an error.
  9. Click the Delete button to remove the bucket from the account.

Using buckets via the S3 API (examples)

Create a new bucket

A PUT issued to the endpoint root will create a bucket when a string is provided. Bucket names must be unique, and accounts are limited to 100 buckets each. Bucket names must be DNS-compliant; names between 3 and 63 characters long must be made of lowercase letters, numbers, and dashes. Bucket names must begin and end with a lowercase letter or number. Bucket names resembling IP addresses are not allowed.
Note: Using third-party tools or SDKs may enforce setting a ‘Location Constraint’ when creating a bucket. If required, this value must be set to ‘us-standard’.

Syntax

PUT https://{endpoint}/{bucket-name} # path style
PUT https://{bucket-name}.{endpoint} # virtual host style

Sample request

This is an example of creating a new bucket called ‘images’.

PUT /images HTTP/1.1
Content-Type: text/plain
Host: s3-api.us-geo.objectstorage.softlayer.net
X-Amz-Date: 20160821T052842Z
Authorization:{authorization-string}

Sample response

HTTP/1.1 200 OK
Date: Wed, 24 Aug 2016 17:45:25 GMT
X-Clv-Request-Id: dca204eb-72b5-4e2a-a142-808d2a5c2a87
Accept-Ranges: bytes
Server: Cleversafe/3.9.0.115
X-Clv-S3-Version: 2.5
x-amz-request-id: dca204eb-72b5-4e2a-a142-808d2a5c2a87
Content-Length: 0

Providing a Location Constraint

To specify a Location Constraint, provide an XML block that describes the configuration in the body of the request (as well as a x-amz-content-sha256 header with the hashed request body).

<CreateBucketConfiguration>
  <LocationConstraint>us-standard</LocationConstraint>
</CreateBucketConfiguration>

Delete a bucket

A DELETE issued to an empty bucket deletes the bucket. Only empty buckets can be deleted.

Syntax

DELETE https://{endpoint}/{bucket-name} # path style
DELETE https://{bucket-name}.{endpoint} # virtual host style

Sample request

DELETE /images HTTP/1.1
Host: s3-api.us-geo.objectstorage.softlayer.net
x-amz-date: 20160822T064812Z
Authorization: {authorization-string}

The server responds with 204 No Content.

If a non-empty bucket is requested for deletion, the server responds with 409 Conflict.

Sample request

DELETE /apiary HTTP/1.1
Authorization: {authorization-string}
x-amz-date: 20160825T174049Z
Host: s3-api.us-geo.objectstorage.softlayer.net

Sample response

<Error>
  <Code>BucketNotEmpty</Code>
  <Message>The bucket you tried to delete is not empty.</Message>
  <Resource>/apiary/</Resource>
  <RequestId>9d2bbc00-2827-4210-b40a-8107863f4386</RequestId>
  <httpStatusCode>409</httpStatusCode>
</Error>