Obtaining Bucket Metadata
API Description
You can use this API to send a HEAD request to a bucket to obtain the bucket metadata such as the storage class and CORS rules (if set).
Method Definition
ObsClient.getBucketMetadata(bucketName, origin, requestHeaders)
Request Parameters
| Field | Type | Optional or Mandatory | Description |
|---|---|---|---|
| bucketName | str | Mandatory | Bucket name |
| origin | str | Optional | Origin of the cross-domain request specified by the pre-request. Generally, it is a domain name. |
| requestHeaders | str | Optional | HTTP headers in a cross-domain request |
Returned Results
| Type | Description |
|---|---|
| SDK common result object |
| GetResult.body Type | Description |
|---|---|
| Response result of the request for obtaining bucket metadata |
Sample Code
try:
resp = obsClient.getBucketMetadata('bucketname', 'http://www.a.com', 'x-obs-header')
if resp.status < 300:
print('requestId:', resp.requestId)
print('storageClass:', resp.body.storageClass)
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('status:', resp.status)
except:
import traceback
print(traceback.format_exc()) Last Article: Listing Versioned Objects in a Bucket
Next Article: Obtaining a Bucket Location
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.