All Products
Search
Document Center

Object Storage Service:GetObjectMeta

Last Updated:Oct 29, 2024

Queries the metadata of an object, including the ETag, size, and last modified time of the object. The content of the object is not returned.

Usage notes

Note

If the object is a symbolic link, information about the symbolic link is returned.

To query the metadata of an object in an unversioned bucket, you must have the oss:GetObject permission. To query the metadata of a specific version of an object in a versioning-enabled bucket, you must have the oss:GetObjectVersion permission. To specify the version of the object, specify the x-oss-version-id header in the request. For more information, see Attach a custom policy to a RAM user.

Versioning

By default, the GetObjectMeta operation queries the metadata of the current version of an object. If the current version of the object is a delete marker, Object Storage Service (OSS) returns 404 Not Found. If you specify a version ID in the request, OSS returns the metadata of the specified version of the object.

Request structure

HEAD /ObjectName?objectMeta HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue

Request headers

All headers in a DescribeRegions request are common request headers. For more information, see Common request headers.

Response parameters

Response headers

Type

Example

Description

Content-Length

String

344606

The size of the object. Unit: bytes.

ETag

String

5B3C1A2E053D763E1B002CC607C5****

The ETag that is generated when an object is created. ETags are used to identify the content of the objects.

If an object is created by calling the PutObject operation, the ETag of the object is the MD5 hash of the object content. If an object is created by using another method, the ETag of the object is not the MD5 hash of the object content but a unique value calculated based on a specific rule. The ETag of an object can be used to check whether the object content changes. However, we recommend that you use the MD5 hash of an object rather than the ETag of the object to verify data integrity.

By default, this header is left empty.

x-oss-transition-time

String

Tue, 23 Apr 2024 07:21:42 GMT

The time when the storage class of the object is converted to Cold Archive or Deep Cold Archive based on lifecycle rules.

Note
  • If the object is stored for more than 180 days after the storage class of the object is converted, you are not charged for the storage usage of the Cold Archive or Deep Cold Archive object that is stored for less than the minimum storage duration. If the object is stored for less than 180 days after the storage class of the object is converted, you are charged for the storage usage of the Cold Archive or Deep Cold Archive object that is stored for less than the minimum storage duration.

  • You cannot use this header to query the time when the storage class of the object is converted to Infrequent Access (IA) or Archive based on lifecycle rules. You can determine whether the object is stored for more than the minimum storage duration based on the value of the Last-Modified header.

x-oss-last-access-time

String

Tue, 30 Mar 2021 06:07:48 GMT

The time when the object was last accessed. The time must be the GMT time specified in HTTP/1.1. If access tracking is enabled, the value of this header is continuously updated as the object is accessed. If access tracking is enabled and then disabled, the value of this header is the time when the object was last accessed.

Important

The last access time of an object is updated asynchronously. OSS guarantees that the last access time of the object is updated within 24 hours. If you access an object multiple times within 24 hours, the last access time of the object is updated to the time when you access the object for the first time within the period.

Last-Modified

String

Fri, 24 Feb 2012 06:07:48 GMT

The time when the object was last modified. The time must be the GMT time specified in HTTP/1.1.

Note
  • The minimum storage duration (30 days) of IA objects is calculated based on the last modified time of the objects. If the value of the Last-Modified header is 30 days earlier than the current time, you are not charged for the storage usage of the IA object that is stored for less than the minimum storage duration.

  • The minimum storage duration (60 days) of Archive objects is calculated based on the last modified time of the objects. If the value of the Last-Modified header is 60 days earlier than the current time, you are not charged for the storage usage of the Archive object that is stored for less than the minimum storage duration.

x-oss-version-id

String

CAEQNRiBgIDMh4mD0BYiIDUzNDA4OGNmZjBjYTQ0YmI4Y2I4ZmVlYzJlNGVk****

The version ID of the object. This header is returned only if you query the metadata of a specific version of the object.

The response to this request contains common response headers. For more information, see Common response headers.

Examples

  • Query the metadata of an object in an unversioned bucket

    Sample requests

    HEAD /oss.jpg?objectMeta HTTP/1.1
    Host: oss-example.oss-cn-hangzhou.aliyuncs.com
    Date: Wed, 29 Apr 2015 05:21:12 GMT
    Authorization: OSS qn6q**************:77Dv****************

    Sample success responses

    Important

    If you create a directory by calling the CreateDirectory operation after you enable hierarchical namespace for a bucket, null is returned for the ETag when you call the GetObjectMeta operation to query the directory information.

    • If access tracking is disabled for the bucket

      HTTP/1.1 200 OK
      x-oss-request-id: 559CC9BDC755F95A6448****
      Date: Wed, 29 Apr 2015 05:21:12 GMT
      ETag: "5B3C1A2E053D763E1B002CC607C5****"
      Last-Modified: Fri, 24 Feb 2012 06:07:48 GMT
      Content-Length: 344606
      Connection: keep-alive
      Server: AliyunOSS
    • If access tracking is enabled for the bucket

      HTTP/1.1 200 OK
      x-oss-request-id: 559CC9BDC755F95A6448****
      Date: Wed, 29 Apr 2015 05:21:12 GMT
      ETag: "5B3C1A2E053D763E1B002CC607C5****"
      x-oss-transition-time: Tue, 23 Apr 2024 07:21:42 GMT
      x-oss-last-access-time: Thu, 14 Oct 2021 11:49:05 GMT
      Last-Modified: Fri, 24 Feb 2012 06:07:48 GMT
      Content-Length: 344606
      Connection: keep-alive
      Server: AliyunOSS
  • Query the metadata of an object in a versioning-enabled bucket

    Sample requests

    GET /example?objectMeta&versionId=CAEQNRiBgIDMh4mD0BYiIDUzNDA4OGNmZjBjYTQ0YmI4Y2I4ZmVlYzJlNGVk**** HTTP/1.1
    Host: versioning-test.oss-cn-hangzhou.aliyuncs.com
    Date: Tue, 09 Apr 2019 06:24:00 GMT
    Authorization: OSS qn6q**************:77Dv****************

    Sample success responses

    • If access tracking is disabled for the bucket

      HTTP/1.1 200 OK
      x-oss-version-id: CAEQNRiBgIDMh4mD0BYiIDUzNDA4OGNmZjBjYTQ0YmI4Y2I4ZmVlYzJlNGVk****
      x-oss-request-id: 5CAC3A80B7AEADE0170005F6
      Date: Tue, 09 Apr 2019 06:24:00 GMT
      ETag: "1CF5A685959CA2ED8DE6E5F8ACC2****"
      Last-Modified: Tue, 09 Apr 2019 06:24:00 GMT
      Content-Length: 119914
      Connection: keep-alive
      Server: AliyunOSS
    • If access tracking is enabled for the bucket

      HTTP/1.1 200 OK
      x-oss-version-id: CAEQNRiBgIDMh4mD0BYiIDUzNDA4OGNmZjBjYTQ0YmI4Y2I4ZmVlYzJlNGVk****
      x-oss-request-id: 5CAC3A80B7AEADE0170005F6
      Date: Tue, 09 Apr 2019 06:24:00 GMT
      ETag: "1CF5A685959CA2ED8DE6E5F8ACC2****"
      x-oss-last-access-time: Thu, 14 Oct 2021 11:49:05 GMT
      Last-Modified: Tue, 09 Apr 2019 06:24:00 GMT
      Content-Length: 119914
      Connection: keep-alive
      Server: AliyunOSS

SDK

You can use OSS SDKs for the following programming languages to call the GetObjectMeta operation:

References

For more information about object metadata, see Manage object metadata.

Error codes

Error code

HTTP status code

Description

Not Found

404

The specified object does not exist.