• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (PHP SDK)
  4. Bucket Management
  5. Setting or Obtaining a Bucket Quota

Setting or Obtaining a Bucket Quota

Setting a Bucket Quota

You can call ObsClient->setBucketQuota to set the bucket quota. 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->setBucketQuota([
       'Bucket' => 'bucketname',
       'StorageQuota' => 1024 * 1024 * 100
]);

printf("RequestId:%s\n",$resp['RequestId']);
NOTE:
  • Use the StorageQuota parameter to specify the bucket quota.
  • A bucket quota must be a non-negative integer expressed in bytes. The maximum value is 263 - 1.

Obtaining a Bucket Quota

You can call ObsClient->getBucketQuota to obtain the bucket quota. 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->getBucketQuota([
       'Bucket' => 'bucketname'
]);

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