• Object Storage Service

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

OPTIONS Bucket

API Description

You can use this API to pre-request a bucket that is configured with CORS.

Method Definition

ObsClient.optionsBucket(bucketName, option)

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

option

Options

Mandatory

Additional parameter of OPTIONS Bucket

Returned Result

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

OptionsResponse

Response result of OPTIONS Bucket

Sample Code

try:
    from com.obs.models.options import Options 
     
    option = Options(origin='http://www.a.com', accessControlRequestMethods=['GET', 'POST'], 
                     accessControlRequestHeaders=['header1', 'header2']) 
     
    resp = obsClient.optionsBucket('bucketname', option) 
      
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        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) 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())