Obtaining Object Metadata
API Description
You can use this API to send a HEAD request to the object of a specified bucket to obtain its metadata.
Method Definition
1. ObsClient->getObjectMetadata(array $parameter) 2. ObsClient->getObjectMetadataAsync(array $parameter, callable $callback)
Request Parameter
Field | Type | Optional or Mandatory | Description |
|---|---|---|---|
Bucket | string | Mandatory | Bucket name |
Key | string | Mandatory | Object name |
VersionId | string | Optional | Object version ID |
Origin | string | Optional | Origin of the cross-domain request specified by the pre-request. Generally, it is a domain name. |
RequestHeader | string | Optional | HTTP header in a cross-domain request |
Returned Result
Field | Type | Description |
|---|---|---|
HttpStatusCode | integer | HTTP status code |
Reason | string | Reason description |
RequestId | string | Request ID returned by the OBS server |
LastModified | string | Time when the last modification was made to the object |
ContentLength | integer | Object size in bytes |
ContentType | string | MIME type of the object. For details about the common content types, see . |
ETag | string | Object ETag |
VersionId | string | Object version ID |
WebsiteRedirectLocation | string | Location where the object is redirected to, when the bucket is configured with website hosting. |
StorageClass | string | Storage class of the object. When the storage class is OBS Standard, the value is null. |
Restore | string | Restoration status of the object in the Cold storage class. |
AllowOrigin | string | If Origin in the request meets the CORS rules of the bucket, AllowedOrigin in the CORS rules is returned. |
AllowHeader | string | If RequestHeader in the request meets the CORS rules of the bucket, AllowedHeader in the CORS rules is returned. |
AllowMethod | string | AllowedMethod in the CORS rules of the bucket |
ExposeHeader | string | ExposeHeader in the CORS rules of the bucket |
MaxAgeSeconds | integer | MaxAgeSeconds in the CORS rules of the bucket |
Expiration | string | Expiration details |
Metadata | associative array | Customized metadata of the object |
Sample Code
try { $resp = $obsClient->getObjectMetadata( [ 'Bucket' => 'bucketname', 'Key' => 'objectkey' ] ); printf ( "RequestId:%s\n", $resp ['RequestId'] ); printf ( "ETag:%s\n", $resp ['ETag'] ); printf ( "VersionId:%s\n", $resp ['VersionId'] ); printf ( "ContentLength:%s\n", $resp ['ContentLength'] ); printf ( "LastModified:%s\n", $resp ['LastModified'] ); printf ( "Expiration:%s\n", $resp ['Expiration'] ); printf ( "StorageClass:%s\n", $resp ['StorageClass'] ); } catch ( Obs\Common\ObsException $obsException ) { printf ( "ExceptionCode:%s\n", $obsException->getExceptionCode () ); printf ( "ExceptionMessage:%s\n", $obsException->getExceptionMessage () ); }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot
