Introduction
The IBM® Cloud Object Storage API is a REST-based API for reading and writing objects. It uses IBM Cloud® Identity and Access Management for authentication/authorization, and supports a subset of the S3 API for easy migration of applications to IBM Cloud.
For details about using Object Storage, see the IBM Cloud docs.
Object Storage is a global service. The location of data is determined by the region where a bucket is created, and subsequent requests to that bucket must be sent to the same corresponding endpoint. The examples shown here assume that requests are sent to the US South region. For more details about selecting endpoints Object Storage, see the IBM Cloud docs.
This document covers only a subset of methods. For more information about all the methods, see About the IBM Cloud Object Storage S3 API.
Java developers can use this SDK to interact with Object Storage. The SDK is a fork of the official AWS SDK for Java. For more information, see the COS SDK for Java API Reference.
JavaScript developers can use this SDK to interact with Object Storage. The SDK is a fork of the official AWS SDK for JavaScript. For more information, see the COS SDK for JavaScript API Reference.
The SDK is supported on Node versions 4.x and later.
Python developers can use this SDK to interact with Object Storage. The SDK is a fork of the boto3 library. For more information, see the COS SDK for Python API Reference.
Go developers can use this SDK to interact with Object Storage. The SDK is a fork of the official AWS SDK for Go. For more information, see the COS SDK for Go API Reference.
The SDK supports Go versions 1.10 - 1.12.
The code examples on this tab use the client library that is provided for Java.
Maven
<dependency>
<groupId>com.ibm.cos</groupId>
<artifactId>ibm-cos-java-sdk</artifactId>
</dependency>
GitHub
The code examples on this tab use the client library that is provided for Node.js.
Installation
npm install ibm-cos-sdk
GitHub
The code examples on this tab use the client library that is provided for Python.
Installation
pip install --upgrade ibm-cos-sdk
GitHub
The code examples on this tab use the client library that is provided for Go.
go get -u github.com/IBM/ibm-cos-sdk-go
GitHub
Error handling
The Object Storage service uses standard HTTP response codes to indicate if a method completes successfully. A 200
response always indicates success. A 400
type response is some sort of failure, and a 500
type response usually indicates an internal system error.
For more details about response codes Object Storage, see the IBM Cloud docs.
Methods
Request
No Request Parameters
Response
Status Code
Success
{ "Buckets": [ { "CreationDate": "2012-02-15T21: 03: 02.000Z", "Name": "examplebucket" }, { "CreationDate": "2011-07-24T19: 33: 50.000Z", "Name": "examplebucket2" }, { "CreationDate": "2010-12-17T00: 56: 49.000Z", "Name": "examplebucket3" } ], "Owner": { "DisplayName": "own-display-name", "ID": "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31" } }
Request
Path Parameters
Response
Status Code
Success
BucketAlreadyExists
BucketAlreadyOwnedByYou
{ "Location": "/examplebucket" }
List objects
Returns some or all (up to 1000) of the objects in a bucket. You can use the request parameters as selection criteria to return a subset of the objects in a bucket.
GET /{Bucket}?
Request
Path Parameters
Query Parameters
Pagination limit
Pagination token
Response
A flag that indicates whether or not Amazon S3 returned all of the results that satisfied the search criteria.
When response is truncated (the IsTruncated element value in the response is true), you can use the key name in this field as marker in the subsequent request to get next set of objects. IBM COS lists objects in alphabetical order Note: This element is returned only if you have delimiter request parameter specified. If response does not include the NextMaker and it is truncated, you can use the value of the last Key in the response as the marker in the subsequent request to get the next set of object keys.
Encoding type used to encode object keys in the response.
Possible values: [
url
]
Status Code
Success
NoSuchBucket
{ "Contents": [ { "ETag": "\"70ee1738b6b21e2c8a43f3a5ab0eee71\"", "Key": "example1.jpg", "LastModified": "2014-11-21T19:40:05.000Z", "Owner": { "DisplayName": "myname", "ID": "12345example25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc" }, "Size": 11, "StorageClass": "STANDARD" }, { "ETag": "\"9c8af9a76df052144598c115ef33e511\"", "Key": "example2.jpg", "LastModified": "2013-11-15T01:10:49.000Z", "Owner": { "DisplayName": "myname", "ID": "12345example25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc" }, "Size": 713193, "StorageClass": "STANDARD" } ], "NextMarker": "eyJNYXJrZXIiOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAyfQ==" }
Check a bucket's headers
This operation is useful to determine if a bucket exists and you have permission to access it.
HEAD /{Bucket}?
Request
Path Parameters
Response
Status Code
Success
NoSuchBucket
Delete a bucket.
Deletes the bucket. All objects in the bucket must be deleted before the bucket itself can be deleted.
DELETE /{Bucket}?
Request
Path Parameters
Response
Status Code
Success
No Sample Response
Request
Path Parameters
Object data.
Response
Status Code
Success
{ "ETag": "\"6805f2cfc46c0f04559748bb039d69ae\"", "ServerSideEncryption": "AES256", "VersionId": "CG612hodqujkf8FaaNfp8U..FIhLROcp" }
Request
Path Parameters
Response
Object data.
Status Code
Success
NoSuchKey
{ "AcceptRanges": "bytes", "ContentLength": "10", "ContentRange": "bytes 0-9/43", "ContentType": "text/plain", "ETag": "\"0d94420ffd0bc68cd3d152506b97a9cc\"", "LastModified": "Thu, 09 Oct 2014 22:57:28 GMT", "Metadata": {}, "VersionId": "null" }
Check an object''s headers
The HEAD operation retrieves metadata from an object without returning the object itself. This operation is useful if you're only interested in an object's metadata. To use HEAD, you must have READ access to the object.
HEAD /{Bucket}/{Key}
Request
Path Parameters
Response
Status Code
Success
NoSuchKey
Request
Path Parameters
Response
Status Code
Success
{}