• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (PHP SDK)
  4. Bucket-Related APIs
  5. GET Buckets

GET Buckets

API Description

You can use this API to obtain the bucket list. In the list, bucket names are displayed in lexicographical order.

Method Definition

1. ObsClient->listBuckets()
2. ObsClient->listBucketsAsync(callable $callback)

Request Parameter

None.

Returned Result

Field

Type

Description

HttpStatusCode

integer

HTTP status code

Reason

string

Reason description

RequestId

string

Request ID returned by the OBS server

Buckets

indexed array

List of buckets

  

Name

string

Bucket name

CreationDate

string

Time when the bucket is created

Owner

associative array

Bucket owner

  

ID

string

ID of the domain to which the bucket owner belongs

DisplayName

string

Name of the bucket owner

Sample Code

try{
       $resp = $obsClient -> listBuckets();
       printf("RequestId:%s\n", $resp['RequestId']);
       printf("Owner[ID]:%s\n", $resp['Owner']['ID']);
       printf("Owner[DisplayName]:%s\n", $resp['Owner']['DisplayName']);
       foreach ($resp['Buckets'] as $index => $bucket){
              printf("Buckets[%d]\n", $index + 1);
              printf("Name:%s\n", $bucket['Name']);
              printf("CreationDate:%s\n", $bucket['CreationDate']);
       }
}catch (Obs\Common\ObsException $obsException){
       printf("ExceptionCode:%s\n", $obsException->getExceptionCode());              
       printf("ExceptionMessage:%s\n", $obsException->getExceptionMessage());
}