Updated on 2026-01-16 GMT+08:00

Storage Class

OBS allows you to set storage classes for buckets. The storage class of an object defaults to be that of its residing bucket. Different storage classes meet different needs for storage performance and costs. There are three types of storage class for buckets, as described in the following table:

Storage Class

Description

Value in OBS Android SDK

OBS Standard

Features low access latency and high throughput and is applicable to storing frequently-accessed (multiple times per month) hotspot or small objects (< 1 MB) requiring quick response.

StorageClassEnum.STANDARD

OBS Warm

Is applicable to storing semi-frequently accessed (less than 12 times a year) data requiring quick response.

StorageClassEnum.WARM

OBS Cold

Is applicable to archiving rarely-accessed (once a year) data.

StorageClassEnum.COLD

Intelligent Tiering

Is designed to optimize storage costs by automatically moving data to a more economical access tier when data access patterns change. This storage class is ideal for data with constantly changing or unpredictable access patterns.

StorageClassEnum.INTELLIGENTTIERING

Setting the Storage Class for a Bucket

You can call ObsClient.setBucketStoragePolicy to set the storage class for a bucket. Sample code is as follows:

// Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
// Obtain an AK/SK pair on the management console.
String ak = System.getenv("ACCESS_KEY_ID");
String sk = System.getenv("SECRET_ACCESS_KEY_ID");
String endPoint = "https://your-endpoint";
// Create an ObsClient instance.
ObsClient obsClient = new ObsClient(ak, sk, endPoint);

// Set the storage class to Warm.
BucketStoragePolicyConfiguration storgePolicy = new BucketStoragePolicyConfiguration();
storgePolicy.setBucketStorageClass(StorageClassEnum.WARM);
obsClient.setBucketStoragePolicy("bucketname", storgePolicy);

Obtaining the Storage Class of a Bucket

You can call ObsClient.getBucketStoragePolicy to obtain the storage class of a bucket. Sample code is as follows:

// Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
// Obtain an AK/SK pair on the management console.
String ak = System.getenv("ACCESS_KEY_ID");
String sk = System.getenv("SECRET_ACCESS_KEY_ID");
String endPoint = "https://your-endpoint";
// Create an ObsClient instance.
ObsClient obsClient = new ObsClient(ak, sk, endPoint);

BucketStoragePolicyConfiguration storagePolicy = obsClient.getBucketStoragePolicy("bucketname");
Log.i("GetBucketStoragePolicy", "\t" + storagePolicy.getBucketStorageClass());