Query metadata for a bucket or object using the stat command. Use it to check storage class, access control list (ACL), redundancy type, object size, and other properties directly from the command line.
Only the bucket owner and RAM users with the oss:GetObject, oss:GetObjectAcl, and oss:GetBucketInfo permissions can query object metadata using stat.
Prerequisites
Before you begin, ensure that you have:
ossutil installed. For ossutil 1.6.16 and later, use
ossutildirectly as the binary name. For earlier versions, update the binary name based on your operating system. See ossutil command referenceThe required permissions to query the bucket or object
Command syntax
ossutil stat oss://bucketname[/objectname]
[--encoding-type <value>]
[--payer <value>]
[--version-id <value>]Parameters and options
| Parameter/Option | Required | Description |
|---|---|---|
bucketname | Yes | Name of the bucket. |
objectname | No | Name of the object. Omit to query bucket-level information. |
--encoding-type | No | Encoding format for the object name. Valid value: url. If not specified, the object name is not encoded. |
--payer | No | Set to requester to make the requester pay the traffic and request fees generated by this operation. |
--version-id | No | Version ID of the object. Applies only to versioning-enabled or versioning-suspended buckets. |
Examples
Query bucket information
ossutil stat oss://examplebucketSample output:
Name : examplebucket
Location : oss-cn-hangzhou
CreationDate : 2021-06-30 16:04:41 +0800 CST
ExtranetEndpoint : oss-cn-hangzhou.aliyuncs.com
IntranetEndpoint : oss-cn-hangzhou-internal.aliyuncs.com
ACL : private
Owner : 148562088256****
StorageClass : Standard
RedundancyType : LRS
AccessMonitor : Enabled
0.132413(s) elapsedOutput fields:
| Field | Description |
|---|---|
Name | Bucket name. |
Location | Region where the bucket is located. |
CreationDate | Date and time the bucket was created. |
ExtranetEndpoint | Public endpoint for accessing the bucket over the internet. |
IntranetEndpoint | Internal endpoint for accessing the bucket within the Alibaba Cloud internal network. |
ACL | Bucket-level access control list (ACL). |
Owner | Alibaba Cloud account ID of the bucket owner. |
StorageClass | Storage class of the bucket. |
RedundancyType | Data redundancy type. |
AccessMonitor | Whether access monitoring is enabled for the bucket. |
Query object information
ossutil stat oss://examplebucket/exampleobject.jpgSample output:
ACL : default
Accept-Ranges : bytes
Content-Length : 8746
Content-Md5 : cvc5wcklut76CVoEi2UW****
Content-Type : image/jpeg
Etag : 72F739C1C925BADEFA095A048B65****
Last-Modified : 2021-07-27 09:53:03 +0800 CST
Owner : 148562088256****
X-Oss-Hash-Crc64ecma : 56037670485008****
X-Oss-Object-Type : Normal
X-Oss-Storage-Class : Standard
0.194739(s) elapsedOutput fields:
| Field | Description |
|---|---|
ACL | Object-level ACL. default means the object inherits the bucket ACL. |
Accept-Ranges | Indicates the server supports range requests (bytes). |
Content-Length | Object size in bytes. |
Content-Md5 | Base64-encoded MD5 hash of the object content, used for data integrity verification. |
Content-Type | MIME type of the object. |
Etag | Entity tag that identifies a specific version of the object. Changes when the object content changes. |
Last-Modified | Date and time the object was last modified. |
Owner | Alibaba Cloud account ID of the object owner. |
X-Oss-Hash-Crc64ecma | CRC64 checksum of the object, used for end-to-end data integrity verification. |
X-Oss-Object-Type | Upload type used to create the object. Normal indicates a standard (non-multipart) upload. |
X-Oss-Storage-Class | Storage class of the object. |
Query an object with special characters in its name
ossutil supports only URL encoding for object names. To query an object whose name contains special characters, encode the name as URL-safe characters first.
For example, to query the 示例.txt object:
ossutil stat oss://examplebucket/%E7%A4%BA%E4%BE%8B.txt --encoding-type urlSample output:
ACL : default
Accept-Ranges : bytes
Content-Length : 113089
Content-Md5 : mAYgHM5cSkZNBxKDDqqW****
Content-Type : image/jpeg
Etag : 9806201CCE5C4A464D0712830EAA****
Last-Modified : 2021-07-27 10:08:57 +0800 CST
Owner : 148562088256****
X-Oss-Hash-Crc64ecma : 1106061527435521****
X-Oss-Object-Type : Normal
X-Oss-Storage-Class : Standard
0.168335(s) elapsedQuery a specific object version
ossutil stat oss://examplebucket/test.jpg --version-id CAEQFRiBgICw.YSX1xciIDNiNzc3ZTdmNTQzOTQ1OTM4MWUwOWI1Y2M1ZTgz****Sample output:
ACL : default
Accept-Ranges : bytes
Content-Length : 190540
Content-Md5 : aJQnxHQ2b+zW6hh0c+2y****
Content-Type : image/jpeg
Etag : 689427C474366FECD6EA187473ED****
Last-Modified : 2021-07-27 10:19:25 +0800 CST
Owner : 148562088256****
X-Oss-Hash-Crc64ecma : 1666171672179499****
X-Oss-Object-Type : Normal
X-Oss-Storage-Class : Standard
X-Oss-Version-Id : CAEQFRiBgICw.YSX1xciIDNiNzc3ZTdmNTQzOTQ1OTM4MWUwOWI1Y2M1ZTgz****
0.213528(s) elapsedThe output includes X-Oss-Version-Id in addition to the standard object fields. To look up the version ID first, see ls.
Cross-account and cross-region queries
To query a bucket in a different region or owned by a different Alibaba Cloud account, add the -e, -i, and -k options to specify the endpoint, AccessKey ID, and AccessKey secret:
ossutil stat oss://testbucket \
-e oss-cn-shanghai.aliyuncs.com \
-i yourAccessKeyID \
-k yourAccessKeySecretFor a full list of common options, see Common options.