Returns metadata about all versions of the objects in a bucket. You can also use request parameters as selection criteria to return metadata about a subset of all the object versions.
s3:ListBucketVersions
action. Be aware of the name difference.200 OK
response can contain valid or invalid XML. Make sure to design your application to parse the contents of the response and handle it appropriately.To use this operation, you must have READ access to the bucket.
The following operations are related to ListObjectVersions
:
See also: AWS API Documentation
list-object-versions
is a paginated operation. Multiple API calls may be issued in order to retrieve the entire data set of results. You can disable pagination by providing the --no-paginate
argument.
When using --output text
and the --query
argument on a paginated response, the --query
argument must extract data from the results of the following query expressions: Versions
, DeleteMarkers
, CommonPrefixes
list-object-versions
--bucket <value>
[--delimiter <value>]
[--encoding-type <value>]
[--prefix <value>]
[--expected-bucket-owner <value>]
[--request-payer <value>]
[--optional-object-attributes <value>]
[--cli-input-json | --cli-input-yaml]
[--starting-token <value>]
[--page-size <value>]
[--max-items <value>]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
[--cli-binary-format <value>]
[--no-cli-pager]
[--cli-auto-prompt]
[--no-cli-auto-prompt]
--bucket
(string)
The bucket name that contains the objects.
--delimiter
(string)
A delimiter is a character that you specify to group keys. All keys that contain the same string between theprefix
and the first occurrence of the delimiter are grouped under a single result element inCommonPrefixes
. These groups are counted as one result against themax-keys
limitation. These keys are not returned elsewhere in the response.
--encoding-type
(string)
Encoding type used by Amazon S3 to encode the object keys in the response. Responses are encoded only in UTF-8. An object key can contain any Unicode character. However, the XML 1.0 parser can’t parse certain characters, such as characters with an ASCII value from 0 to 10. For characters that aren’t supported in XML 1.0, you can add this parameter to request that Amazon S3 encode the keys in the response. For more information about characters to avoid in object key names, see Object key naming guidelines .
Note
When using the URL encoding type, non-ASCII characters that are used in an object’s key name will be percent-encoded according to UTF-8 code values. For example, the objecttest_file(3).png
will appear astest_file%283%29.png
.Possible values:
url
--prefix
(string)
Use this parameter to select only those keys that begin with the specified prefix. You can use prefixes to separate a bucket into different groupings of keys. (You can think of usingprefix
to make groups in the same way that you’d use a folder in a file system.) You can useprefix
withdelimiter
to roll up numerous objects into a single result underCommonPrefixes
.
--expected-bucket-owner
(string)
The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code403 Forbidden
(access denied).
--request-payer
(string)
Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. If either the source or destination S3 bucket has Requester Pays enabled, the requester will pay for corresponding charges to copy the object. For information about downloading objects from Requester Pays buckets, see Downloading Objects in Requester Pays Buckets in the Amazon S3 User Guide .
Note
This functionality is not supported for directory buckets.Possible values:
requester
--optional-object-attributes
(list)
Specifies the optional fields that you want returned in the response. Fields that you do not specify are not returned.
(string)
Syntax:
"string" "string" ...
Where valid values are:
RestoreStatus
--cli-input-json
| --cli-input-yaml
(string)
Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml
.
--starting-token
(string)
A token to specify where to start paginating. This is the
NextToken
from a previously truncated response.For usage examples, see Pagination in the AWS Command Line Interface User Guide .
--page-size
(integer)
The size of each page to get in the AWS service call. This does not affect the number of items returned in the command’s output. Setting a smaller page size results in more calls to the AWS service, retrieving fewer items in each call. This can help prevent the AWS service calls from timing out.
For usage examples, see Pagination in the AWS Command Line Interface User Guide .
--max-items
(integer)
The total number of items to return in the command’s output. If the total number of items available is more than the value specified, a
NextToken
is provided in the command’s output. To resume pagination, provide theNextToken
value in thestarting-token
argument of a subsequent command. Do not use theNextToken
response element directly outside of the AWS CLI.For usage examples, see Pagination in the AWS Command Line Interface User Guide .
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. Similarly, if provided yaml-input
it will print a sample input YAML that can be used with --cli-input-yaml
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command. The generated JSON skeleton is not stable between versions of the AWS CLI and there are no backwards compatibility guarantees in the JSON skeleton generated.
--debug
(boolean)
Turn on debug logging.
--endpoint-url
(string)
Override command’s default URL with the given URL.
--no-verify-ssl
(boolean)
By default, the AWS CLI uses SSL when communicating with AWS services. For each SSL connection, the AWS CLI will verify SSL certificates. This option overrides the default behavior of verifying SSL certificates.
--no-paginate
(boolean)
Disable automatic pagination. If automatic pagination is disabled, the AWS CLI will only make one call, for the first page of results.
--output
(string)
The formatting style for command output.
--query
(string)
A JMESPath query to use in filtering the response data.
--profile
(string)
Use a specific profile from your credential file.
--region
(string)
The region to use. Overrides config/env settings.
--version
(string)
Display the version of this tool.
--color
(string)
Turn on/off color output.
--no-sign-request
(boolean)
Do not sign requests. Credentials will not be loaded if this argument is provided.
--ca-bundle
(string)
The CA certificate bundle to use when verifying SSL certificates. Overrides config/env settings.
--cli-read-timeout
(int)
The maximum socket read time in seconds. If the value is set to 0, the socket read will be blocking and not timeout. The default value is 60 seconds.
--cli-connect-timeout
(int)
The maximum socket connect time in seconds. If the value is set to 0, the socket connect will be blocking and not timeout. The default value is 60 seconds.
--cli-binary-format
(string)
The formatting style to be used for binary blobs. The default format is base64. The base64 format expects binary blobs to be provided as a base64 encoded string. The raw-in-base64-out format preserves compatibility with AWS CLI V1 behavior and binary values must be passed literally. When providing contents from a file that map to a binary blob fileb://
will always be treated as binary and use the file contents directly regardless of the cli-binary-format
setting. When using file://
the file contents will need to properly formatted for the configured cli-binary-format
.
--no-cli-pager
(boolean)
Disable cli pager for output.
--cli-auto-prompt
(boolean)
Automatically prompt for CLI input parameters.
--no-cli-auto-prompt
(boolean)
Disable automatically prompt for CLI input parameters.
To use the following examples, you must have the AWS CLI installed and configured. See the Getting started guide in the AWS CLI User Guide for more information.
Unless otherwise stated, all examples have unix-like quotation rules. These examples will need to be adapted to your terminal’s quoting rules. See Using quotation marks with strings in the AWS CLI User Guide .
The following command retrieves version information for an object in a bucket named my-bucket
:
aws s3api list-object-versions --bucket my-bucket --prefix index.html
Output:
{
"DeleteMarkers": [
{
"Owner": {
"DisplayName": "my-username",
"ID": "7009a8971cd660687538875e7c86c5b672fe116bd438f46db45460ddcd036c32"
},
"IsLatest": true,
"VersionId": "B2VsEK5saUNNHKcOAJj7hIE86RozToyq",
"Key": "index.html",
"LastModified": "2015-11-10T00:57:03.000Z"
},
{
"Owner": {
"DisplayName": "my-username",
"ID": "7009a8971cd660687538875e7c86c5b672fe116bd438f46db45460ddcd036c32"
},
"IsLatest": false,
"VersionId": ".FLQEZscLIcfxSq.jsFJ.szUkmng2Yw6",
"Key": "index.html",
"LastModified": "2015-11-09T23:32:20.000Z"
}
],
"Versions": [
{
"LastModified": "2015-11-10T00:20:11.000Z",
"VersionId": "Rb_l2T8UHDkFEwCgJjhlgPOZC0qJ.vpD",
"ETag": "\"0622528de826c0df5db1258a23b80be5\"",
"StorageClass": "STANDARD",
"Key": "index.html",
"Owner": {
"DisplayName": "my-username",
"ID": "7009a8971cd660687538875e7c86c5b672fe116bd438f46db45460ddcd036c32"
},
"IsLatest": false,
"Size": 38
},
{
"LastModified": "2015-11-09T23:26:41.000Z",
"VersionId": "rasWWGpgk9E4s0LyTJgusGeRQKLVIAFf",
"ETag": "\"06225825b8028de826c0df5db1a23be5\"",
"StorageClass": "STANDARD",
"Key": "index.html",
"Owner": {
"DisplayName": "my-username",
"ID": "7009a8971cd660687538875e7c86c5b672fe116bd438f46db45460ddcd036c32"
},
"IsLatest": false,
"Size": 38
},
{
"LastModified": "2015-11-09T22:50:50.000Z",
"VersionId": "null",
"ETag": "\"d1f45267a863c8392e07d24dd592f1b9\"",
"StorageClass": "STANDARD",
"Key": "index.html",
"Owner": {
"DisplayName": "my-username",
"ID": "7009a8971cd660687538875e7c86c5b672fe116bd438f46db45460ddcd036c32"
},
"IsLatest": false,
"Size": 533823
}
]
}
IsTruncated -> (boolean)
A flag that indicates whether Amazon S3 returned all of the results that satisfied the search criteria. If your results were truncated, you can make a follow-up paginated request by using theNextKeyMarker
andNextVersionIdMarker
response parameters as a starting place in another request to return the rest of the results.
KeyMarker -> (string)
Marks the last key returned in a truncated response.
VersionIdMarker -> (string)
Marks the last version of the key returned in a truncated response.
NextKeyMarker -> (string)
When the number of responses exceeds the value ofMaxKeys
,NextKeyMarker
specifies the first key not returned that satisfies the search criteria. Use this value for the key-marker request parameter in a subsequent request.
NextVersionIdMarker -> (string)
When the number of responses exceeds the value ofMaxKeys
,NextVersionIdMarker
specifies the first object version not returned that satisfies the search criteria. Use this value for theversion-id-marker
request parameter in a subsequent request.
Versions -> (list)
Container for version information.
(structure)
The version of an object.
ETag -> (string)
The entity tag is an MD5 hash of that version of the object.ChecksumAlgorithm -> (list)
The algorithm that was used to create a checksum of the object.
(string)
Size -> (long)
Size in bytes of the object.StorageClass -> (string)
The class of storage used to store the object.Key -> (string)
The object key.VersionId -> (string)
Version ID of an object.IsLatest -> (boolean)
Specifies whether the object is (true) or is not (false) the latest version of an object.LastModified -> (timestamp)
Date and time when the object was last modified.Owner -> (structure)
Specifies the owner of the object.
DisplayName -> (string)
Container for the display name of the owner. This value is only supported in the following Amazon Web Services Regions:
- US East (N. Virginia)
- US West (N. California)
- US West (Oregon)
- Asia Pacific (Singapore)
- Asia Pacific (Sydney)
- Asia Pacific (Tokyo)
- Europe (Ireland)
- South America (São Paulo)
Note
This functionality is not supported for directory buckets.ID -> (string)
Container for the ID of the owner.RestoreStatus -> (structure)
Specifies the restoration status of an object. Objects in certain storage classes must be restored before they can be retrieved. For more information about these storage classes and how to work with archived objects, see Working with archived objects in the Amazon S3 User Guide .
IsRestoreInProgress -> (boolean)
Specifies whether the object is currently being restored. If the object restoration is in progress, the header returns the value
TRUE
. For example:x-amz-optional-object-attributes: IsRestoreInProgress="true"
If the object restoration has completed, the header returns the value
FALSE
. For example:x-amz-optional-object-attributes: IsRestoreInProgress="false", RestoreExpiryDate="2012-12-21T00:00:00.000Z"
If the object hasn’t been restored, there is no header response.
RestoreExpiryDate -> (timestamp)
Indicates when the restored copy will expire. This value is populated only if the object has already been restored. For example:
x-amz-optional-object-attributes: IsRestoreInProgress="false", RestoreExpiryDate="2012-12-21T00:00:00.000Z"
DeleteMarkers -> (list)
Container for an object that is a delete marker.
(structure)
Information about the delete marker.
Owner -> (structure)
The account that created the delete marker.>
DisplayName -> (string)
Container for the display name of the owner. This value is only supported in the following Amazon Web Services Regions:
- US East (N. Virginia)
- US West (N. California)
- US West (Oregon)
- Asia Pacific (Singapore)
- Asia Pacific (Sydney)
- Asia Pacific (Tokyo)
- Europe (Ireland)
- South America (São Paulo)
Note
This functionality is not supported for directory buckets.ID -> (string)
Container for the ID of the owner.Key -> (string)
The object key.VersionId -> (string)
Version ID of an object.IsLatest -> (boolean)
Specifies whether the object is (true) or is not (false) the latest version of an object.LastModified -> (timestamp)
Date and time when the object was last modified.
Name -> (string)
The bucket name.
Prefix -> (string)
Selects objects that start with the value supplied by this parameter.
Delimiter -> (string)
The delimiter grouping the included keys. A delimiter is a character that you specify to group keys. All keys that contain the same string between the prefix and the first occurrence of the delimiter are grouped under a single result element inCommonPrefixes
. These groups are counted as one result against themax-keys
limitation. These keys are not returned elsewhere in the response.
MaxKeys -> (integer)
Specifies the maximum number of objects to return.
CommonPrefixes -> (list)
All of the keys rolled up into a common prefix count as a single return when calculating the number of returns.
(structure)
Container for all (if there are any) keys between Prefix and the next occurrence of the string specified by a delimiter. CommonPrefixes lists keys that act like subdirectories in the directory specified by Prefix. For example, if the prefix is notes/ and the delimiter is a slash (/) as in notes/summer/july, the common prefix is notes/summer/.
Prefix -> (string)
Container for the specified common prefix.
EncodingType -> (string)
Encoding type used by Amazon S3 to encode object key names in the XML response.
If you specify the
encoding-type
request parameter, Amazon S3 includes this element in the response, and returns encoded key name values in the following response elements:KeyMarker, NextKeyMarker, Prefix, Key
, andDelimiter
.
RequestCharged -> (string)
If present, indicates that the requester was successfully charged for the request.
Note
This functionality is not supported for directory buckets.