GET Bucket(List Objects)

Last updated: 2021-01-18 18:54:57

    API Description

    The GET Bucket API is equivalent to the List Objects API and can be used to list some or all objects in a bucket. To call this API, you need to have permission to read the bucket.

    Note:

    If you upload an object to the bucket and call the GET Bucket API immediately, due to the eventual consistency characteristic of this API, the response may not include the newly uploaded object.

    Request

    Sample request

    GET / HTTP/1.1
    Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
    Date: GMT Date
    Authorization: Auth String

    Note:

    Authorization: Auth String (see Request Signature for details).

    Request parameters

    Parameter Description Type Required
    prefix Matching prefix for object keys. The response will contain only object keys with the specified prefix. string No
    delimiter A character delimiter used to group object keys. Keys that contain identical paths between the prefix (or, if no prefix is specified, the beginning of the string) and the first delimiter are grouped and defined as a Prefix node under CommonPrefixes. The grouped object keys will no longer appear in the subsequent object list. For specific scenarios and usage, see the samples below. string No
    encoding-type Encoding type of the returned value. Valid value: url, meaning that the returned object keys are URL-encoded (percent-encoded) values. For example, "Tencent Cloud" will be encoded to %E8%85%BE%E8%AE%AF%E4%BA%91. string No
    marker Marker for the starting object key. Object key entries will be returned in UTF-8 lexicographical order, starting from the first object key after the marker. string No
    max-keys The maximum number (up to 1,000) of keys returned in the response. Defaults to 1000.
    Note: This parameter limits the maximum number of keys (the sum of CommonPrefixes and Contents) COS can return in each List Objects response. If not all objects are listed in a single response, COS will return the NextMarker node, the value of which can be used to specify marker so that the remaining objects can be listed in your next request.
    integer No

    Request headers

    This API only uses common request headers. For more information, please see Common Request Headers.

    Request body

    This API does not have a request body.

    Response

    Response headers

    In addition to common response headers, this API also returns the following response headers. For more information about common response headers, please see Common Response Headers.

    Parameter Description Type
    x-cos-bucket-region Bucket region, such as ap-beijing, ap-hongkong, and eu-frankfurt. For the enumerated values, please see Regions and Access Endpoints Enum

    Response body

    A successful query returns application/xml data, which contains information about objects in the bucket. For the response bodies of different scenarios, see the sample below.

    <?xml version='1.0' encoding='utf-8' ?>
    <ListBucketResult>
                <Name>string</Name>
                <EncodingType>string</EncodingType>
                <Prefix>string</Prefix>
                <Marker>string</Marker>
                <MaxKeys>integer</MaxKeys>
                <Delimiter>string</Delimiter>
                <IsTruncated>boolean</IsTruncated>
                <NextMarker>string</NextMarker>
                <CommonPrefixes>
                    <Prefix>string</Prefix>
                </CommonPrefixes>
                <CommonPrefixes>
                    <Prefix>string</Prefix>
                </CommonPrefixes>
                <Contents>
                    <Key>string</Key>
                    <LastModified>date</LastModified>
                    <ETag>string</ETag>
                    <Size>integer</Size>
                    <Owner>
                        <ID>string</ID>
                        <DisplayName>string</DisplayName>
                    </Owner>
                    <StorageClass>Enum</StorageClass>
                    <StorageTier>Enum</StorageTier>
                </Contents>
                <Contents>
                    <Key>string</Key>
                    <LastModified>date</LastModified>
                    <ETag>string</ETag>
                    <Size>integer</Size>
                    <Owner>
                        <ID>string</ID>
                        <DisplayName>string</DisplayName>
                    </Owner>
                    <StorageClass>Enum</StorageClass>
                    <StorageTier>Enum</StorageTier>
                </Contents>
    </ListBucketResult>

    The nodes are described as follows:

    Node Name (Keyword) Parent Node Description Type
    ListBucketResult None Stores the result of the GET Bucket request. Container

    Content of the Container node ListBucketResult:

    Node Name (Keyword) Parent Node Description Type
    Name ListBucketResult Bucket name, formatted as <BucketName-APPID>, such as examplebucket-1250000000 string
    EncodingType ListBucketResult Encoding type, which corresponds to the encoding-type parameter in the request. This node will be returned only when the encoding-type parameter is specified in the request. string
    Prefix ListBucketResult Matching prefix to filter object keys. This node corresponds to the Prefix parameter in the request. string
    Marker ListBucketResult Marks the object key to start with. Object keys after the marker will be returned in UTF-8 lexicographical order. This node corresponds to the marker parameter in the request. string
    MaxKeys ListBucketResult Maximum number of keys returned in a single response. This node corresponds to the max-keys parameter in the request. integer
    Delimiter ListBucketResult Delimiter, which corresponds to the delimiter parameter in the request and will be returned only if the delimiter parameter is specified in the request. string
    IsTruncated ListBucketResult Indicates whether the returned list is truncated. Valid values: true, false boolean
    NextMarker ListBucketResult This node will be returned only if the returned list is truncated (i.e., the value of IsTruncated is true). The value of this node is the last obje