Add and delete Object / File in COS (S3)

Using objects from the Bluemix portal

  1.     The objects present within a bucket can be viewed, by clicking the bucket name on the buckets list.
  2.     The header is updated to include the following info:
  3.         Name of the account currently being viewed
    •         The current region being viewed
    •         The name of the bucket whose objects are currently displayed
    •         The type of the bucket whose objects are currently displayed
  4.     Above the grid on the left is a link with the name of the bucket currently viewed. Click the link to show the list of buckets again.
  5.     The grid shows the list of objects in the bucket.
  6.     A new object can be added, by clicking the + button at the right of the first row.
  7.     The file can be selected from the file system, by clicking the select button and the new file uploaded, by clicking the Add button. When using the portal to add an object, file size is limited to 20 megabytes. (When using the API, objects as large as 5 gigabytes can be uploaded in a single PUT, and as large as 5 terabytes when using a multi-part upload.)
  8.     An object can be deleted, by clicking on the red - button to the extreme right of the object name. This opens a confirmation window.
  9.     Click the Delete button to remove the object from the bucket.

Using objects from control.softlayer.com

  1.     From the bucket view, click a bucket you wish to use.
  2.     The header is updated to include the following info:
  3.         Name of the account currently being viewed
    •         The current region being viewed
    •         The name of the bucket whose objects are currently displayed
    •         The type of the bucket whose objects are currently displayed
  4.     Above the grid on the left is a link with the name of the bucket currently viewed. Click the link to show the list of buckets again.
  5.     The grid shows the list of objects in the bucket.
  6.     A new object can be added, by clicking the + button at the right of the first row.
  7.     The file can be selected from the file system, by clicking the select button and the new file uploaded, by clicking the Add button. When using the portal to add an object, file size is limited to 20 megabytes. (When using the API, objects as large as 5 gigabytes can be uploaded in a single PUT, and as large as 5 terabytes when using a multi-part upload.)
  8.     An object can be deleted, by clicking on the red - button to the extreme right of the object name. This opens a confirmation window.
  9.     Click the Delete button to remove the object from the bucket.


Using objects via the S3 API

Upload an object

A PUT given a path to an object uploads the request body as an object. A SHA256 hash of the object is a required header.

Syntax

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

Sample request

PUT /apiary/queen-bee HTTP/1.1
Authorization: {authorization-string}
x-amz-date: 20160825T183001Z
x-amz-content-sha256: 309721641329cf441f3fa16ef996cf24a2505f91be3e752ac9411688e3435429
Content-Type: text/plain; charset=utf-8
Host: s3-api.us-geo.objectstorage.softlayer.net
Content-Length: 533

The 'queen' bee is developed from larvae selected by worker bees and fed a
substance referred to as 'royal jelly' to accelerate sexual maturity. After a
short while the 'queen' is the mother of nearly every bee in the hive, and
the colony will fight fiercely to protect her.

Sample response

HTTP/1.1 200 OK
Date: Thu, 25 Aug 2016 18:30:02 GMT
X-Clv-Request-Id: 9f0ca49a-ae13-4d2d-925b-117b157cf5c3
Accept-Ranges: bytes
Server: Cleversafe/3.9.0.121
X-Clv-S3-Version: 2.5
x-amz-request-id: 9f0ca49a-ae13-4d2d-925b-117b157cf5c3
ETag: "3ca744fa96cb95e92081708887f63de5"
Content-Length: 0

Delete an object

A DELETE given a path to an object deletes an object.

Syntax

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

Sample request

DELETE /apiary/soldier-bee HTTP/1.1
Authorization: {authorization-string}
Host: s3-api.sjc-us-geo.objectstorage.softlayer.net

Sample response

HTTP/1.1 204 No Content
Date: Thu, 25 Aug 2016 17:44:57 GMT
X-Clv-Request-Id: 8ff4dc32-a6f0-447f-86cf-427b564d5855
Accept-Ranges: bytes
Server: Cleversafe/3.9.0.121
X-Clv-S3-Version: 2.5
x-amz-request-id: 8ff4dc32-a6f0-447f-86cf-427b564d5855

Deleting multiple objects

A POST given a path to an bucket and proper parameters will delete a specified set of objects.

Syntax

POST https://{endpoint}/{bucket-name}/{object-name}?delete= # path style
POST https://{bucket-name}.{endpoint}/{object-name}?delete= # virtual host style

Sample request

POST /apiary?delete= HTTP/1.1
Authorization: {authorization-string}
Host: s3-api.us-geo.objectstorage.softlayer.net
x-amz-date: 20161205T231624Z
x-amz-content-sha256: 3ade096cd9471017539ede10c4d8aa05a1ecd015a16f4f090e9fcee92a816cf4
Content-MD5: zhi+TmIAhD2U3GfoYayyTQ==
Content-Type: text/plain; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<Delete>
    <Object>
         <Key>surplus-bee</Key>
    </Object>
    <Object>
         <Key>unnecessary-bee</Key>
    </Object>
</Delete>

Sample response

HTTP/1.1 200 OK
Date: Wed, 30 Nov 2016 18:54:53 GMT
X-Clv-Request-Id: a6232735-c3b7-4c13-a7b2-cd40c4728d51
Accept-Ranges: bytes
Server: Cleversafe/3.9.0.137
X-Clv-S3-Version: 2.5
x-amz-request-id: a6232735-c3b7-4c13-a7b2-cd40c4728d51
Content-Type: application/xml
Content-Length: 207

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DeleteResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <Deleted>
         <Key>surplus-bee</Key>
    </Deleted>
    <Deleted>
         <Key>unnecessary-bee</Key>
    </Deleted>
</DeleteResult>


More information:

COS S3 API reference: https://ibm-public-cos.github.io/crs-docs/crs-api-reference.html