# 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 deletion 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 | Yes
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 a decryption algorithm. The header is used in SSE-C mode. 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 a key used to decrypt objects. The header is used in SSE-C mode.

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 a key used to decrypt objects. The header is used in SSE-C mode. 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 following message headers may also be used. For details, see Table 3.

Table 3 Additional response header parameters
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 Possible values are GET, PUT, HEAD, POST, and 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 is the ID of the region to which the key belongs. domainID is the account ID of the tenant to which the key belongs. key_id is 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

For a Cold object that is being restored or has been restored, this header is returned. Indicates the object restoring status. Value options are as follows: restoring ongoing-request=true; you have obtained ongoing-request=false, expiry-date=Wed, 07 Nov 2012 00:00:00 GMT. In the preceding information, expiry-date indicates the expiration time after the object is restored.

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

#### Response Elements

This response involves 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

Parent topic: Operations on Objects