Skip to main content

ListObjectsV2

Returns some or all (up to 1000) of the objects in a bucket.

Description

The ListObjectsV2 operation returns some or all (up to 1000) of the objects in a bucket. You can use the request parameters as selection criteria to return a subset of the objects in a bucket. To use this operation, you must have s3:ListBucket permissions on the bucket, or be the bucket owner.

note
  • This operation returns up to 1000 objects at a time.
  • To get the next set of objects, use the continuation-token from the previous response.
  • For better performance when listing objects with many prefixes, use the delimiter parameter.
  • A 200 OK response can contain valid or invalid XML.

Request Syntax

GET /?list-type=2&continuation-token=Token&delimiter=Delimiter&encoding-type=EncodingType&fetch-owner=FetchOwner&max-keys=MaxKeys&prefix=Prefix&start-after=StartAfter HTTP/1.1
Host: BucketName.qstorage.quilibrium.com
x-amz-expected-bucket-owner: OwnerAccountId
Values in italics indicate user input and should be replaced with actual values.

This operation does not have a request body.

Request Parameters

URI Parameters

NameDescriptionRequiredType
list-typeMust be set to 2 to use ListObjectsV2Yesnumber
continuation-tokenToken to continue listing more objects. Used for pagination.Notext
delimiterCharacter used to group keysNotext
encoding-typeEncoding type used by QStorage to encode object key names in the responseNotext
fetch-ownerSpecifies whether to include owner information in the responseNoboolean
max-keysMaximum number of keys to return in the responseNonumber
prefixLimits the response to keys that begin with the specified prefixNotext
start-afterStart listing after this specified keyNotext

Headers

NameDescriptionRequiredType
x-amz-expected-bucket-ownerThe account ID of the expected bucket ownerNotext
x-amz-request-payerConfirms that the requester knows that they will be charged for the request.

Valid Values: requester
Notext

Examples

Example 1: List objects in a bucket

GET /?list-type=2 HTTP/1.1
Host: my-bucket.qstorage.quilibrium.com
Values in italics indicate user input and should be replaced with actual values.
HTTP/1.1 200 OK
x-amz-id-2: Example7qoYGN7uMuFuYS6m7a4l
x-amz-request-id: TX234S0F24A06C7
Date: Wed, 01 Mar 2024 12:00:00 GMT
<?xml version="1.0" encoding="UTF-8"?> <ListBucketResult> <Name>my-bucket</Name> <Prefix></Prefix> <KeyCount>2</KeyCount> <MaxKeys>1000</MaxKeys> <IsTruncated>false</IsTruncated> <Contents> <Key>hello.txt</Key> <LastModified>2024-03-01T11:00:00.000Z</LastModified> <ETag>"7778aef83f66abc1fa1e8477f296d394"</ETag> <Size>11</Size> <StorageClass>STANDARD</StorageClass> </Contents> <Contents> <Key>document.txt</Key> <LastModified>2024-03-01T11:30:00.000Z</LastModified> <ETag>"7778aef83f66abc1fa1e8477f296d394"</ETag> <Size>11</Size> <StorageClass>STANDARD</StorageClass> </Contents> </ListBucketResult>
Values in italics indicate variable response values.

Example 2: List objects with a prefix and delimiter

GET /?list-type=2&prefix=documents/&delimiter=/ HTTP/1.1
Host: my-bucket.qstorage.quilibrium.com
Values in italics indicate user input and should be replaced with actual values.
HTTP/1.1 200 OK
x-amz-id-2: Example7qoYGN7uMuFuYS6m7a4l
x-amz-request-id: TX234S0F24A06C7
Date: Wed, 01 Mar 2024 12:00:00 GMT
<?xml version="1.0" encoding="UTF-8"?> <ListBucketResult> <Name>my-bucket</Name> <Prefix>documents/</Prefix> <Delimiter>/</Delimiter> <KeyCount>2</KeyCount> <MaxKeys>1000</MaxKeys> <IsTruncated>false</IsTruncated> <Contents> <Key>documents/report.pdf</Key> <LastModified>2024-03-01T11:00:00.000Z</LastModified> <ETag>"7778aef83f66abc1fa1e8477f296d394"</ETag> <Size>52428800</Size> <StorageClass>STANDARD</StorageClass> </Contents> <CommonPrefixes> <Prefix>documents/2024/</Prefix> </CommonPrefixes> </ListBucketResult>
Values in italics indicate variable response values.

Response Syntax

HTTP/1.1 200 OK
x-amz-id-2: RequestId
x-amz-request-id: AmazonRequestId
Date: ISO8601Date
<?xml version="1.0" encoding="UTF-8"?> <ListBucketResult> <Name>BucketName</Name> <Prefix>Prefix</Prefix> <StartAfter>StartAfter</StartAfter> <KeyCount>KeyCount</KeyCount> <MaxKeys>MaxKeys</MaxKeys> <Delimiter>Delimiter</Delimiter> <IsTruncated>true|false</IsTruncated> <Contents> <Key>ObjectKey</Key> <LastModified>ISO8601Date</LastModified> <ETag>EntityTag</ETag> <Size>Size</Size> <Owner> <ID>OwnerId</ID> <DisplayName>OwnerName</DisplayName> </Owner> <StorageClass>StorageClass</StorageClass> </Contents> <CommonPrefixes> <Prefix>CommonPrefix</Prefix> </CommonPrefixes> </ListBucketResult>
Values in italics indicate variable response values.

Response Elements

Response Headers

NameDescriptionRequiredType
x-amz-id-2An identifier for the requestNoString
x-amz-request-idA unique identifier for the requestNoString
x-amz-request-chargedIf present, indicates that the requester was successfully charged for the request.

Valid Values: requester
NoString
DateThe date and time at which the response was sentNoString

Response Body Elements

NameDescriptionRequiredType
ListBucketResultContainer for responseNoString
NameName of the bucketNoString
PrefixKeys that begin with the indicated prefixNoString
StartAfterKey to start listing fromNoString
KeyCountNumber of keys returnedNoString
MaxKeysMaximum number of keys that could have been returnedNoString
DelimiterCharacter used to group keys. Keys containing the same string between the prefix and the first occurrence of the delimiter are grouped under a single CommonPrefixes element. These grouped keys are not listed individually elsewhere in the response and each group counts as one item against the MaxKeys limit.NoString
IsTruncatedIndicates whether the returned list of objects is truncatedNoString
ContentsContains information about each Object returned. Each Object is returned as a Contents elementNoString
KeyThe object keyNoString
LastModifiedDate and time the object was last modifiedNoString
ContinuationTokenIf ContinuationToken was sent with the request, it is included in the response. You can use this ContinuationToken for pagination of the list results.NoString
NextContinuationTokenToken to use in a subsequent request to get the next set of objects, if there are any remaining.NoString
ETagThe entity tag is an MD5 hash of the objectNoString
EncodingTypeEncoding type used to encode object key names in the XML response. If specified in the request, this element is included in the response, and encoded key name values are returned in the following response elements: Delimiter, Prefix, Key, and StartAfter.NoString
SizeSize in bytes of the objectNoString
OwnerBucket owner informationNoString
StorageClassStorage class used for storing the objectNoString
CommonPrefixesGroups of keys that share identical patterns up to the next delimiter character. These common prefixes only appear in the response when a delimiter parameter is specified.NoString

Special Errors

Error CodeDescription
NoSuchBucketThe specified bucket does not exist
403Forbidden. Authentication failed or you do not have permission to list objects

Permissions

You must have the s3:ListBucket permission.

Try It Out

Test ListObjectsV2

List objects in a bucket.

Coming Soon

This feature is currently under development and will be available soon.