• Object Storage Service

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

OPTIONS Object

API Description

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

Method Definition

ObsClient.optionsObject(bucketName, objectKey, option)

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

objectKey

str

Mandatory

Object name

option

Options

Mandatory

Additional parameter of OPTIONS Object

Returned Result

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

OptionsResponse

Response result of OPTIONS Object

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.optionsObject('bucketname', 'objectkey', 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())