Obtaining the CORS Configuration Information of a Bucket
API Description
You can use this API to obtain the CORS configuration information of a specified bucket.
Method Definition
ObsClient.getBucketCors(bucketName)
Request Parameters
|
Field |
Type |
Optional or Mandatory |
Description |
|---|---|---|---|
|
bucketName |
str |
Mandatory |
Bucket name |
Returned Results
|
Type |
Description |
|---|---|
|
SDK common result object |
|
GetResult.body Type |
Description |
|---|---|
|
list of CorsRule |
List of CORS rules of a bucket |
Sample Code
try:
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
else:
print('errorCode:', resp.errorCode)
print('errorMessage:', resp.errorMessage)
except:
import traceback
print(traceback.format_exc())
Last Article: Configuring CORS Rules for a Bucket
Next Article: Deleting CORS Rules of a Bucket
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.