• Object Storage Service

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

Obtaining Bucket Metadata

You can call ObsClient->getBucketMetadata to obtain the metadata 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->getBucketMetadata([
       'Bucket' => 'bucketname',
       'Origin' => 'http://www.a.com'
]);

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