You can use the stat command to view information about a specified bucket or object. For example, you can view the storage class of a bucket and the metadata of an object.
-
Starting from ossutil 1.6.16, you can use `ossutil` as the binary name in the command line. You do not need to change the binary name for different operating systems. If you use a version of ossutil earlier than 1.6.16, you must use the binary name specific to your operating system. For more information, see ossutil command reference.
-
Only the bucket owner and Resource Access Management (RAM) users who have the
oss:GetObject,oss:GetObjectAcl, andoss:GetBucketInfopermissions can use this command to view object metadata.
Command syntax
ossutil stat oss://bucketname[/objectname]
[--encoding-type <value>]
[--payer <value>]
[--version-id <value>]
The following table describes the parameters and options.
|
Parameter |
Description |
|
bucketname |
The name of the destination bucket. |
|
objectname |
The name of the destination object. |
|
--encoding-type |
The encoding method for the object name. Set the value to url. If you do not specify this option, the object name is not encoded. |
|
--payer |
The payment method for the request. If you want the requester to pay for fees, such as traffic and requests, that are generated by accessing resources in the specified path, set this option to requester. |
|
--version-id |
The version of the object. This option applies only to objects in a bucket for which versioning is enabled or suspended. |
Examples
-
View information about the `examplebucket` bucket.
ossutil stat oss://examplebucketThe following output shows the information that is returned for `examplebucket`. The information includes the bucket name, region, creation time, and access control list (ACL).
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) elapsed -
View information about the `exampleobject.jpg` object in the `examplebucket` bucket.
ossutil stat oss://examplebucket/exampleobject.jpgThe following output shows the information that is returned for `exampleobject.jpg`. The information includes the ACL and file metadata, such as Content-Type, ETag value, and last modified time.
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) elapsed -
View information about an object whose name contains special characters in the `examplebucket` bucket.
For example, to view information about the example.txt object in the `examplebucket` bucket. If an object name contains special characters that cannot be entered or recognized, you must URL-encode the object name because ossutil supports only URL encoding for object names.
ossutil stat oss://examplebucket/%E7%A4%BA%E4%BE%8B.txt --encoding-type urlThe following response provides information about
Example.txt, including its Access Control List (ACL), Content-Type, ETag value, and last modified time.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) elapsed -
View information about a specific version of an object in the `examplebucket` bucket.
ossutil stat oss://examplebucket/test.jpg --version-id CAEQFRiBgICw.YSX1xciIDNiNzc3ZTdmNTQzOTQ1OTM4MWUwOWI1Y2M1ZTgz****For more information about how to obtain object versions, see ls.
The following output shows the information that is returned for the specified version of the object. The information includes the ACL, file metadata such as Content-Type, ETag value, last modified time, and version ID.
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) elapsed
Common options
To access a bucket in a different region, use -e to specify the endpoint. To access a bucket owned by a different Alibaba Cloud account, use -i for the AccessKey ID and -k for the AccessKey secret.
For example, to obtain information about the `testbucket` bucket that is in the China (Shanghai) region and belongs to another Alibaba Cloud account, run the following command:
ossutil stat oss://testbucket -e oss-cn-shanghai.aliyuncs.com -i yourAccessKeyID -k yourAccessKeySecret