aws s3api list-objects
This operation is not supported for directory buckets. AWS CLI reference
1 example 9 options Its page in the AWS CLI reference
Examples
To list the objects in a bucket
The following list-objects example displays the names of all the objects in the specified bucket.
aws s3api list-objects --bucket amzn-s3-demo-bucket --query 'Contents[].{Key: Key, Size: Size}'Identify--bucketThe name of the bucket containing the objects.--queryA JMESPath query to use in filtering the response data.Its output
[
{
"Key": "dir/my_data",
"Size": 20000
},
{
"Key": "dir/my_images.tar.bz2",
"Size": 3191
}
]The example uses the --query argument to filter the output of list-objects down to the key value and size for each object
For more information, see Listing object keys programmatically in the Amazon S3 User Guide.
Options
--bucketThe name of the bucket containing the objects.--delimiterA delimiter is a character that you use to group keys.--encoding-typeEncoding type used by Amazon S3 to encode the object keys in the response.--expected-bucket-ownerThe account ID of the expected bucket owner.--markerMarker is where you want Amazon S3 to start listing from.--max-keysSets the maximum number of keys returned in the response.--optional-object-attributesSpecifies the optional fields that you want returned in the response.--prefixLimits the response to keys that begin with the specified prefix.--request-payerConfirms that the requester knows that she or he will be charged for the list objects request.