All Products
Search
Document Center

Object Storage Service:stat

Last Updated:Aug 30, 2023

This topic describes how to run the stat command to query the information of buckets or objects. For example, you can run this command to query the storage class of a bucket and the metadata of an object.

Important
  • Sample command lines in this topic are based on the 64-bit Linux system. For other systems, replace ./ossutil64 in the commands with the corresponding binary name. For more information, see ossutil.

  • Only the bucket owner and Resource Access Management (RAM) users that are granted the oss:GetObject, oss:GetObjectAcl, and oss:GetBucketInfo permissions are allowed to view object metadata by running this command.

Command syntax

./ossutil64 stat oss://bucketname[/objectname]
[--encoding-type <value>]
[--payer <value>]
[--version-id <value>]

The following table describes the parameters that you can configure when you run this command.

Parameter

Description

bucketname

The name of the bucket whose information you want to query.

objectname

The name of the object whose information you want to query.

--encoding-type

The method to encode the object name. Valid value: url. If this option is not specified, the object name is not encoded.

--payer

The payer of the traffic and request fees incurred when the command is run. If you want the requester who accesses the resources in the specified path to pay for the traffic and request fees incurred during queries, set this parameter to requester.

--version-id

The ID of the version of the object. This parameter applies only to objects in buckets for which versioning is enabled or suspended.

Examples

  • Query the information of the examplebucket bucket.

     ./ossutil64 stat oss://examplebucket

    If a similar output is displayed, the information of the examplebucket bucket is obtained, which includes the region, creation time, and access control list (ACL) of this bucket:

    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
  • Query the information of the exampleobject.jpg object stored in the examplebucket bucket.

    ./ossutil64 stat oss:///examplebucket/exampleobject.jpg

    If a similar output is displayed, the information of the examplebucket object is obtained, which includes the ETag value, last modified time, and metadata such as the ACL and Contend-Type:

    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
  • Query the information of objects whose names contain special characters and that are stored in the examplebucket bucket.

    For example, you want to query the information of the object whose name is example txt and that is stored in the examplebucket bucket. ossutil only supports URL encoding for object names. If an object name contains special characters, you can encode these special characters before you use the object name in the command.

    ./ossutil64 stat oss://examplebucket/%E7%A4%BA%E4%BE%8B.txt --encoding-type url

    If a similar output is displayed, the information of the example txt object is obtained, which includes the ETag value, last modified time, and metadata such as the ACL and Contend-Type:

    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
  • Query the information of the object of a specified version in the examplebucket bucket.

    ./ossutil64 stat oss://examplebucket/test.jpg --version-id  CAEQFRiBgICw.YSX1xciIDNiNzc3ZTdmNTQzOTQ1OTM4MWUwOWI1Y2M1ZTgz****

    For more information about how to query all versions of an object, see Is.

    If a similar output is displayed, the information of the object of the specified version is obtained, which includes the ETag value, last modified time, version ID, and metadata such as the ACL and Contend-Type:

    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

If you use ossutil to switch to a bucket that is located in another region, add the -e option to the command to specify the endpoint of the region in which the specified bucket is located. If you use ossutil to switch to a bucket that belongs to another Alibaba Cloud account, you can add the -i option to the command to specify the AccessKey ID of the specified account, and add the -k option to the command to specify the AccessKey secret of the specified account.

For example, you can run the following command to query the information of the testbucket bucket that is located in the China (Shanghai) region and owned by another Alibaba Cloud account:

./ossutil64 stat oss://testbucket  -e oss-cn-shanghai.aliyuncs.com -i LTAI4Fw2NbDUCV8zYUzA****  -k 67DLVBkH7EamOjy2W5RVAHUY9H****

For more information about other common options that you can use for the sync command, see Common options.