Object storage

You can store and retrieve files by using the Object Storage service in IBM Bluemix.

Object storage is an electronic storage that is highly scalable, easy to use, cost-effective, provides huge capacity, and is a distributed system that spans regions and even countries. It is commonly used for storing pictures, documents, audio, video, system backups, and database dumps.

IBM Bluemix offers a range of object storage services. Bluemix infrastructure provides the Cloud Object Storage service that has two service types:

Cross-region service

This service provides resiliency across three geographic regions and encryption of data at rest and in flight. Data is accessible via an S3-compatible API.

Regional service

This service is available in 20 IBM Cloud data centers worldwide and implements an OpenStack Object Storage API. The Bluemix PaaS catalog Object Storage service also provides an OpenStack Object Storage API.

Create a container in the Object Storage service

Before you use any API services of Bluemix PaaS OpenStack-based object storage, an authentication token must be obtained by using Keystone. Perform Keystone authentication by POST of the credentials provided in the VCAP_SERVICES to https://identity.open.softlayer.com/v3/auth/tokens. After the token is obtained, containers and objects can be managed through REST API calls to the storage URL that is returned with the token.

After authentication is complete, create a container in object storage with a PUT request to the storage URL, appending the new container name in the request.

curl -i -H "X-Auth-Token: AUTH_tk924cd97c2af7475c8e6cb25d2adaccf8" -X PUT https://dal05.objectstorage.softlayer.net/v1/AUTH_0c6bf5d5-b5e4-43aa-93f1-ea7065837fb8/myNewContainer

Run create, upload, and list operations on an object by using containers

After you create the container, objects are manipulated by HTTP requests. To create a file or upload with new data to an existing file, use the PUT command by specifying the container in the path. (This command is simplified by omitting the –H option.)

curl -X PUT [...] storageurl/container1 -T object.jpg

To list all of the objects in a container, use the GET command by specifying the container name. This is a simplified command:

curl –X GET [...] storageurl/container1

To download an object, use the GET command by specifying the object name (simplified command shown):

curl -X GET [...] storageurl/container1/object.jpg

Use metadata to store information about files in object storage

For objects that are stored in object storage, information about the object is available through metadata. Object metadata includes some standard types such as last modified, length, md5 checksum, expiration date, and also supports custom data through the X-Object-Meta-{name} element. Reading metadata from an object is done by using the HEAD request:

curl –X HEAD [...] storageurl/container1

Object metadata is created or updated with the HTTP POST command. Selected standard metadata can be modified, and X-Object-Meta-{name} items can be created as needed.

Related links

IBM Cloud Object Storage

OpenStack Object Storage API