Obtaining Object Metadata
API Description
You can use this API to send a HEAD request to obtain the metadata of an object in a specified bucket.
Method Definition
ObsClient.getObjectMetadata(bucketName, objectKey, versionId, sseHeader, origin, requestHeaders)
Request Parameters
| Field | Type | Optional or Mandatory | Description |
|---|---|---|---|
| bucketName | str | Mandatory | Bucket name |
| objectKey | str | Mandatory | Object name |
| versionId | str | Optional | Object version ID |
| 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 |
| sseHeader | Optional | Header for server-side decryption |
Returned Results
| Type | Description |
|---|---|
| SDK common result object |
| GetResult.body Type | Description |
|---|---|
| Response result of the request for obtaining object metadata |
Sample Code
try:
resp = obsClient.getObjectMetadata('bucketname', 'objectkey')
if resp.status < 300:
print('requestId:', resp.requestId)
print('etag:', resp.body.etag)
print('lastModified:', resp.body.lastModified)
print('contentType:', resp.body.contentType)
print('contentLength:', resp.body.contentLength)
else:
print('status:', resp.status)
except:
import traceback
print(traceback.format_exc()) Last Article: Deleting Objects in a Batch
Next Article: Modifying Object Metadata
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.