Obtain 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:
|
SseCKey |
string |
Optional |
Key used in SSE-C decryption, which is calculated by using AES-256 |
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 |
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 |
Restore status of the object in the OBS 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 |
Master key used in SSE-KMS decryption |
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.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot