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 |
| SseC | string | Optional | Algorithm used in SSE-C decryption. The value can be AES256. |
| SseCKey | string | Optional | Custom key used in SSE-C decryption. The value is a Base64-encoded 256-bit key. |
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 Configuring, Editing, and Viewing Object Metadata. |
| 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 Archive 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 |
| SseKms | string | Algorithm used in SSE-KMS decryption |
| SseKmsKey | string | ID of the KMS master key used in SSE-KMS encryption. If this parameter is left blank, the default key is used. To obtain the key ID, see Viewing a Key. |
| SseC | string | Algorithm used in SSE-C decryption |
| SseCKeyMd5 | string | MD5 value of the key used in SSE-C decryption |
| 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.