• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (PHP SDK)
  4. Bucket Management
  5. Storage Class

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 PHP 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.

ObsClient::StorageClassStandard

OBS Warm

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

ObsClient::StorageClassWarm

OBS Cold

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

ObsClient::StorageClassCold

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:

// Import the third-party open source libraries.
require 'vendor/autoload.php';
// Import the SDK code library.
require 'obs-autoloader.php';
// Declare the namespace.
use Obs\S3\ObsClient;
// Create an instance of ObsClient.
$obsClient = new ObsClient([
       'key' => '*** Provide your Access Key ***',
       'secret' => '*** Provide your Secret Key ***',
       'endpoint' => 'https://yourdomainname'
]);

$resp = $obsClient->setBucketStoragePolicy([
       'Bucket' => 'bucketname',
       'StorageClass' => ObsClient::StorageClassWarm
]);

printf("RequestId:%s\n",$resp['RequestId']);
NOTE:

Use the StorageClass parameter to set the storage class for a bucket.

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:

// Import the third-party open source libraries.
require 'vendor/autoload.php';
// Import the SDK code library.
require 'obs-autoloader.php';
// Declare the namespace.
use Obs\S3\ObsClient;
// Create an instance of ObsClient.
$obsClient = new ObsClient([
       'key' => '*** Provide your Access Key ***',
       'secret' => '*** Provide your Secret Key ***',
       'endpoint' => 'https://yourdomainname'
]);

$resp = $obsClient->getBucketStoragePolicy([
       'Bucket' => 'bucketname'
]);

printf("RequestId:%s\n",$resp['RequestId']);
printf("StorageClass:%s\n",$resp['StorageClass']);