You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
Basic Bucket Operations
ListObjectsV2
Copy page
Download PDF
ListObjectsV2

Function description

Call the ListObjectsV2 API to list objects in a bucket.

tip

Compared with ListObjects, ListObjectsV2 is an upgraded API with more comprehensive parameters and resolves the timeout issues present in ListObjects.

Precautions

  • Calling this API requires read access permission to the bucket.
  • A single bucket request returns up to 1,000 objects. You can use the max-keys parameter to set the number of objects returned.

Request syntax

GET /?list-type=2 HTTP/1.1 
Host: bucketname.tos-cn-beijing.volces.com 
Date: GMT Date 
Authorization: authorization string

Request parameters and headers

Use the public request header, see Common parameters for more information.

NameLocationTypeRequiredSample ValueDescription
list-typeQueryIntegerYes2The value 2 means using the ListObjectsV2 interface to list objects in the bucket.
delimiterQueryStringNo-Set the character for grouping object names. The forward slash (/) is usually used as the grouping character.

encoding-type

Query

String

No

url

Specify the encoding type for the returned content. The options are as follows:

  • url: Perform URLEncode following the application/x-www-form-urlencoded standard.
max-keysQueryIntegerNo100Set the maximum number of returned objects. The maximum value is 1000, meaning up to 1000 objects can be returned per request.
prefixQueryStringNoabcList objects with the specified prefix.
start-afterQueryStringNotest.txtSpecify the starting position of the objects listed. You can paginate the object listing by specifying the starting position of the objects.

fetch-owner

Query

Bool

No

false

Whether to return object owner information, values are as follows:

  • true: return object owner information.
  • false: do not return object owner information, default is false.
continuation-tokenQueryStringNowhvFnl2rE5vm9cWvQScxwTuNm0***Specify to start the listing operation from this token, usually obtained from NextContinuationToken returned in the previous request.

Request body elements

There is no request message element in this request.

Response headers

Return the common response message headers. For more information, see common parameters.

Response body elements

NameTypeSample ValueDescription
NameStringtest-bucketBucket name.
PrefixStringabcThe prefix parameter included in the request.
MarkerStringabcThe marker parameter included in the request.
MaxKeysInteger100The max-keys parameter included in the request.
DelimiterStringdThe delimiter parameter passed in the request.
EncodingTypeStringurlThe encoding-type parameter passed in the request.

IsTruncated

Bool

true

Whether the returned result is truncated, the values are as follows:

  • false: all results have been returned.
  • true: there are still results not returned.
StartAfterStringabcdIf the start-after parameter is specified in the request, the response will include the StartAfter element.
ContinuationTokenStringwhvFnl2rE5vm9cWvQScxwTuv***If the request includes the continuation-token parameter, the response contains the ContinuationToken element.

NextContinuationToken

String

whvFnl2rE5vm9cWvQSg0xfckv***

When IsTruncated is true, NextContinuationToken is returned, indicating more data can be listed. The next listing request can use NextContinuationToken to continue listing.

NextContinuationToken value is not a valid object name.

CommonPrefixesArray[{"Prefix": "abcd"}]When the request includes the delimiter parameter, the response contains the CommonPrefixes group information. This element identifies names ending with delimiter and lists common prefixes of objects.

Contents

Array

-

List object information.

Contents is the root node for the parameters Key, LastModified, ETag, Size, StorageClass, Type, HashCrc64ecma, and Owner.

KeyStringabcdeObject name.
LastModifiedString2024-06-06T07:15:20.000ZLast modification time of the object.
ETagString"32185e15494ca8e0eedf12bd218787f6"Tag generated when each object is created, used to uniquely identify an object.
SizeInteger4813Object size.
StorageClassStringSTANDARDObject storage types,For detailed information, please refer to Storage type.

Type

String

Appendable

If the object is not a Normal object, it returns this element. The value description is as follows:

  • Appendable: This object is uploaded with the append-write interface.
  • Symlink: This object is a symbolic link.

The parent node is Contents.

HashCrc64ecma

String

2217460101204276403

Represents the 64-bit CRC value of the object. This value is calculated according to the ECMA-182 standard.

If the object was created before the TOS server supported 64-bit CRC checks, this message header will not appear in the response.

Owner

Object

-

List information about the object owner.

Owner is the root node for the parameters ID and DisplayName.

IDString1234567890Account ID.
DisplayNameStringtest-owner-nameAccount name.

Sample request

GET /?list-type=2 HTTP/1.1 
Host: bucketname.tos-cn-beijing.volces.com 
Date: Fri, 30 Jul 2021 08:05:36 GMT 
Authorization: authorization string

Sample response

HTTP/1.1 200 OK 
x-tos-id-2: dc13a2093d620014-a444ed0 
x-tos-request-id: dc13a2093d620014-a444ed0 
Date: Fri, 30 Jul 2021 06:45:39 GMT 
server: TosServer 
Content-Length: 622 

{ 
    "Name": "bucketName", 
    "Prefix": "", 
    "Marker": "", 
    "MaxKeys": 1000, 
    "IsTruncated": false, 
    "Contents": [ 
        { 
            "Key": "obj1", 
            "LastModified": "2021-08-20T03:10:02.000Z", 
            "ETag": ""8a36be0d764367db4eea2deb16b71543"", 
            "Size": 109, 
            "StorageClass": "STANDARD" 
        }, 
        { 
            "Key": "obj2", 
            "LastModified": "2021-08-20T03:10:06.000Z", 
            "ETag": ""8a36be0d764367db4eea2deb16b71543"", 
            "Size": 109, 
            "StorageClass": "STANDARD" 
        }, 
        { 
            "Key": "obj3", 
            "LastModified": "2021-08-20T03:10:10.000Z", 
            "ETag": ""8a36be0d764367db4eea2deb16b71543"", 
            "Size": 109, 
            "StorageClass": "STANDARD" 
        } 
    ] 
}
Last updated: 2025.06.30 17:27:07