Updated on 2024-01-02 GMT+08:00

Querying Object Metadata

Functions

Users with the read permission on objects can perform the HeadObject operation to obtain metadata of objects. The object metadata is included in the response.

This operation supports server-side encryption.

Versioning

By default, this operation returns the latest metadata of an object. If the object has a delete marker, status code 404 is returned. To obtain the object metadata of a specified version, the versionId parameter can be used to specify the desired version.

Request Syntax

1
2
3
4
HEAD /ObjectName HTTP/1.1 
Host: bucketname.obs.region.example.com
Date: date
Authorization: authorization

Request Parameters

Table 1 describes the request parameters.

Table 1 Request parameters

Parameter

Description

Mandatory

versionId

Object version ID

Type: string

No

Request Headers

This request uses common headers. For details, see Table 3.

In addition, the request can use additional headers, as shown in Table 2.

Table 2 Request headers

Header

Description

Mandatory

Origin

Origin of the cross-domain request specified by the pre-request. Generally, it is a domain name.

Type: string

No

Access-Control-Request-Headers

Indicates the HTTP headers of a request. The request can use multiple HTTP headers.

Type: string

No

x-obs-server-side-encryption-customer-algorithm

Indicates the decryption algorithm when SSE-C is used.

Type: string

Example: x-obs-server-side-encryption-customer-algorithm:AES256

Constraint: This header must be used together with x-obs-server-side-encryption-customer-key and x-obs-server-side-encryption-customer-key-MD5.

No. This header is required when SSE-C is used.

x-obs-server-side-encryption-customer-key

Indicates the decryption key when SSE-C is used.

Type: string

Example: x-obs-server-side-encryption-customer-key:K7QkYpBkM5+hca27fsNkUnNVaobncnLht/rCB2o/9Cw=

Constraint: This header is a Base64-encoded 256-bit key and must be used together with x-obs-server-side-encryption-customer-algorithm and x-obs-server-side-encryption-customer-key-MD5.

No. This header is required when SSE-C is used.

x-obs-server-side-encryption-customer-key-MD5

Indicates the MD5 value of the decryption key when SSE-C is used. The MD5 value is used to check whether any error occurs during the transmission of the key.

Type: string

Example: x-obs-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ==

Constraint: This header is a Base64-encoded 128-bit MD5 value and must be used together with x-obs-server-side-encryption-customer-algorithm and x-obs-server-side-encryption-customer-key.

No. This header is required when SSE-C is used.

Request Elements

This request involves no elements.

Response Syntax

1
2
3
4
5
6
HTTP/1.1 status_code
Content-Type: type
Date: date
Content-Length: length
Etag: etag
Last-Modified: time

Response Headers

The response to the request uses common headers. For details, see Table 1.

In addition to the common response headers, the message headers listed in Table 3 may be used.

Table 3 Additional response headers

Header

Description

x-obs-expiration

When an object has its lifecycle rule, the object expiration time is subject to its lifecycle rule. This header field is use expiry-date to describe the object expiration date. If the lifecycle rule is configured only for the entire bucket not individual objects, the object expiration time is subject to the bucket lifecycle rule. This header field uses the expiry-date and rule-id to describe the detailed expiration information of objects. If no lifecycle rule is configured, this header field is not contained in the response.

Type: string

x-obs-website-redirect-location

Indicates the redirected-to location. If the bucket is configured with website information, this parameter can be set for the object metadata so that the website endpoint will evaluate the request for the object as a 301 redirect to another object in the same bucket or an external URL.

Type: string

x-obs-version-id

Object version ID. If the object has no version number specified, the response does not contain this header.

Type: string

Default value: none

Access-Control-Allow-Origin

Indicates that the origin is included in the response if the origin in the request meets the CORS configuration requirements when CORS is configured for buckets.

Type: string

Access-Control-Allow-Headers

Indicates that the headers are included in the response if headers in the request meet the CORS configuration requirements when CORS is configured for buckets.

Type: string

Access-Control-Max-Age

Value of MaxAgeSeconds in the CORS configuration of the server when CORS is configured for buckets.

Type: integer

Access-Control-Allow-Methods

Indicates that methods in the rule are included in the response if Access-Control-Request-Method in the request meets the CORS configuration requirements when CORS is configured for buckets.

Type: string

Value options: GET, PUT, HEAD, POST, DELETE

Access-Control-Expose-Headers

Value of ExposeHeader in the CORS configuration of a server when CORS is configured for buckets.

Type: string

x-obs-server-side-encryption

This header is included in a response if SSE-KMS is used.

Type: string

Example: x-obs-server-side-encryption:kms

x-obs-server-side-encryption-kms-key-id

Indicates the master key ID. This header is included in a response if SSE-KMS is used.

Type: string

Format: regionID:domainID:key/key_id regionID indicates the ID of the region where the key belongs. domainID indicates the ID of the tenant where the key belongs. key_id indicates the key ID used in this encryption.

Example: x-obs-server-side-encryption-kms-key-id:region:domainiddomainiddomainiddoma0001:key/4f1cd4de-ab64-4807-920a-47fc42e7f0d0

x-obs-server-side-encryption-customer-algorithm

Indicates a decryption algorithm. This header is included in a response if SSE-C is used.

Type: string

Example: x-obs-server-side-encryption-customer-algorithm:AES256

x-obs-server-side-encryption-customer-key-MD5

Indicates the MD5 value of a key used to decrypt objects. This header is included in a response if SSE-C is used.

Type: string

Example: x-obs-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ==

x-obs-storage-class

This header is returned when the storage class of an object is not Standard. The value can be WARM or COLD.

Type: string

x-obs-restore

This header is returned when a Cold object is being restored or has been restored. It represents the object's restore status, which can be ongoing-request="true" (the object is being restored) or ongoing-request="false", expiry-date="Wed, 7 Nov 2012 00:00:00 GMT" (the object has been restored). In these statuses, expiry-date indicates when the restored object will expire.

Type: string

x-obs-object-type

If the object is not a normal one, this header field is returned. The value can be Appendable

Type: string

x-obs-next-append-position

This header field is returned when the object is an appendable object.

Type: integer

x-obs-uploadId

This header is returned if the object is a combination of multiple parts. The header value indicates the ID of the corresponding multipart upload task.

Type: string

x-obs-object-lock-mode

WORM mode that will be applied to the object. Currently, only COMPLIANCE is supported. This header is returned only when the object has any object-level retention policy configured or has the default bucket-level WORM policy applied. To configure this header, the GetObjectRetention permission is required.

Type: string

Example: x-obs-object-lock-mode:COMPLIANCE

x-obs-object-lock-retain-until-date

Indicates the expiration time of the WORM retention. The value must be a UTC time that complies with ISO 8601, for example, 2015-07-01T04:11:15Z. This header is returned only when the object has any object-level retention policy configured or has the default bucket-level WORM policy applied. To configure this header, the GetObjectRetention permission is required.

Type: string

Example: x-obs-object-lock-retain-until-date:2015-07-01T04:11:15Z

Response Elements

This response contains no elements.

Error Responses

No special error responses are returned. For details about error responses, see Table 2.

Sample Request

1
2
3
4
5
6
HEAD /object1 HTTP/1.1
User-Agent: curl/7.29.0
Host: examplebucket.obs.region.example.com
Accept: */*
Date: WED, 01 Jul 2015 04:19:25 GMT
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:/cARjk81l2iExMfQqn6iT3qEZ74=

Sample Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
HTTP/1.1 200 OK
Server: OBS
x-obs-request-id: 8DF400000163D3E4BB5905C41B6E65B6
Accept-Ranges: bytes
ETag: "3b46eaf02d3b6b1206078bb86a7b7013"
Last-Modified: WED, 01 Jul 2015 01:19:21 GMT
Content-Type: binary/octet-stream
x-obs-id-2: 32AAAQAAEAABAAAQAAEAABAAAQAAEAABCSD3nAiTaBoeyt9oHp9vTYtXnLDmwV6D
Date: WED, 01 Jul 2015 04:19:21 GMT
Content-Length: 4572