By default, when you call the HeadObject operation on an object in a versioned bucket, only the metadata of the current version of the object is returned.

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


The following code provides an example on how to query object metadata:
# -*- coding: utf-8 -*-
import oss2
# The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations in OSS is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. 
auth = oss2.Auth('yourAccessKeyId', 'yourAccessKeySecret')
# Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to 
# Specify the bucket name. Example: examplebucket. 
bucket = oss2.Bucket(auth, '', 'examplebucket')

# Add the versionId field to param. 
params = dict()
params['versionId'] = 'yourObjectVersionId'

# Query parts of the object metadata. 
simplifiedmeta = bucket.get_object_meta("yourObjectName", params=params)

# Query all object metadata. 
objectmeta = bucket.head_object("yourObjectName", params=params)


For more information about the API operations that you can call to query the metadata of an object, see HeadObject and GetObjectMeta.