This topic describes how to query the metadata of objects in a versioning-enabled bucket.
Usage notes
The sample code in this topic uses the region ID
cn-hangzhouof the China (Hangzhou) region. By default, the public endpoint is used to access resources in a bucket. If you want to access resources in the bucket by using other Alibaba Cloud services in the same region in which the bucket is located, use an internal endpoint. For more information about the regions and endpoints supported by OSS, see OSS regions and endpoints.In this topic, access credentials are obtained from environment variables. For more information about how to configure access credentials, see Configure access credentials.
To query the metadata of objects, you must have the
oss:GetObjectpermission. For more information, see Grant custom policy to RAM users.
Sample code
References
For the complete sample code that is used to query the metadata of an object, visit GitHub sample.
For more information about the API operation that you can call to query the metadata of an object, see HeadObject and GetObjectMeta.