listObjectVersions method
The following operations are related to ListObjectVersions:
Parameter bucket :
The bucket name that contains the objects.
Parameter delimiter :
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 in
CommonPrefixes. These groups are counted as one result
against the max-keys limitation. These keys are not returned
elsewhere in the response.
CommonPrefixes is filtered out from results if it is not
lexicographically greater than the key-marker.
Parameter expectedBucketOwner :
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 code 403 Forbidden (access denied).
Parameter keyMarker :
Specifies the key to start with when listing objects in a bucket.
Parameter maxKeys :
Sets the maximum number of keys returned in the response. By default, the
action returns up to 1,000 key names. The response might contain fewer
keys but will never contain more. If additional keys satisfy the search
criteria, but were not returned because max-keys was
exceeded, the response contains
. To return the additional
keys, see key-marker and version-id-marker.
Parameter optionalObjectAttributes :
Specifies the optional fields that you want returned in the response.
Fields that you do not specify are not returned.
Parameter prefix :
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 using prefix to make groups in the
same way that you'd use a folder in a file system.) You can use
prefix with delimiter to roll up numerous
objects into a single result under CommonPrefixes.
Parameter versionIdMarker :
Specifies the object version you want to start listing from.
Implementation
Future<ListObjectVersionsOutput> listObjectVersions({
required String bucket,
String? delimiter,
EncodingType? encodingType,
String? expectedBucketOwner,
String? keyMarker,
int? maxKeys,
List<OptionalObjectAttributes>? optionalObjectAttributes,
String? prefix,
RequestPayer? requestPayer,
String? versionIdMarker,
}) async {
final headers = <String, String>{
if (expectedBucketOwner != null)
'x-amz-expected-bucket-owner': expectedBucketOwner.toString(),
if (optionalObjectAttributes != null)
'x-amz-optional-object-attributes':
optionalObjectAttributes.map((e) => e.value).join(', '),
if (requestPayer != null) 'x-amz-request-payer': requestPayer.value,
};
final $query = <String, List<String>>{
if (delimiter != null) 'delimiter': [delimiter],
if (encodingType != null) 'encoding-type': [encodingType.value],
if (keyMarker != null) 'key-marker': [keyMarker],
if (maxKeys != null) 'max-keys': [maxKeys.toString()],
if (prefix != null) 'prefix': [prefix],
if (versionIdMarker != null) 'version-id-marker': [versionIdMarker],
};
final $result = await _protocol.sendRaw(
method: 'GET',
requestUri: '/${Uri.encodeComponent(bucket)}?versions',
queryParams: $query,
headers: headers,
exceptionFnMap: _exceptionFns,
);
final $elem = await _s.xmlFromResponse($result);
return ListObjectVersionsOutput(
commonPrefixes: $elem
.findElements('CommonPrefixes')
.map(CommonPrefix.fromXml)
.toList(),
deleteMarkers: $elem
.findElements('DeleteMarker')
.map(DeleteMarkerEntry.fromXml)
.toList(),
delimiter: _s.extractXmlStringValue($elem, 'Delimiter'),
encodingType: _s
.extractXmlStringValue($elem, 'EncodingType')
?.let(EncodingType.fromString),
isTruncated: _s.extractXmlBoolValue($elem, 'IsTruncated'),
keyMarker: _s.extractXmlStringValue($elem, 'KeyMarker'),
maxKeys: _s.extractXmlIntValue($elem, 'MaxKeys'),
name: _s.extractXmlStringValue($elem, 'Name'),
nextKeyMarker: _s.extractXmlStringValue($elem, 'NextKeyMarker'),
nextVersionIdMarker:
_s.extractXmlStringValue($elem, 'NextVersionIdMarker'),
prefix: _s.extractXmlStringValue($elem, 'Prefix'),
versionIdMarker: _s.extractXmlStringValue($elem, 'VersionIdMarker'),
versions:
$elem.findElements('Version').map(ObjectVersion.fromXml).toList(),
requestCharged: _s
.extractHeaderStringValue($result.headers, 'x-amz-request-charged')
?.let(RequestCharged.fromString),
);
}