• Object Storage Service

  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Python 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 module.
from com.obs.client.obs_client import ObsClient

# Create an instance of ObsClient.
obsClient = ObsClient(
    access_key_id='*** Provide your Access Key ***',    
    secret_access_key='*** Provide your Secret Key ***',    
# Obtain the bucket metadata.
resp = obsClient.getBucketMetadata('bucketname', 'http://www.a.com', 'x-obs-header')
if resp.status < 300:
    print('requestId:', resp.requestId)
    print('storageClass:', resp.body.storageClass)
    print('accessContorlAllowOrigin:', resp.body.accessContorlAllowOrigin)
    print('accessContorlMaxAge:', resp.body.accessContorlMaxAge)    
    print('accessContorlExposeHeaders:', resp.body.accessContorlExposeHeaders)   
    print('accessContorlAllowMethods:', resp.body.accessContorlAllowMethods)
    print('accessContorlAllowHeaders:', resp.body.accessContorlAllowHeaders)
    print('status:', resp.status)