• Object Storage Service

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

Obtaining a Bucket Location

You can call ObsClient.getBucketLocation to obtain the location 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 ***',    
    server='yourdomainname'
)
resp = obsClient.getBucketLocation('bucketname')

if resp.status < 300:
    print('requestId:', resp.requestId)
    print('location:', resp.body.location)
else:
    print('errorCode:', resp.errorCode)
    print('errorMessage:', resp.errorMessage)
NOTE:

When creating a bucket, you can specify its location. For details, see Creating a Bucket.