• Object Storage Service

  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Python SDK)
  4. CORS
  5. Viewing CORS Rules

Viewing CORS Rules

You can call ObsClient.getBucketCors to view CORS rules 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 ***',    
resp = obsClient.getBucketCors('bucketname')
if resp.status < 300:
    print('requestId:', resp.requestId)
    index = 1
    for rule in resp.body:
        print('corsRule [' + str(index) + ']')
        print('id:', rule.id)
        print('allowedMethod', rule.allowedMethod)
        print('allowedOrigin', rule.allowedOrigin)
        print('allowedHeader', rule.allowedHeader)
        print('maxAgeSecond', rule.maxAgeSecond)
        print('exposeHeader', rule.exposeHeader)
        index +=1
    print('errorCode:', resp.errorCode)
    print('errorMessage:', resp.errorMessage)