listObjectVersions method

Future<ListObjectVersionsOutput> listObjectVersions({
  1. required String bucket,
  2. String? delimiter,
  3. EncodingType? encodingType,
  4. String? expectedBucketOwner,
  5. String? keyMarker,
  6. int? maxKeys,
  7. String? prefix,
  8. String? versionIdMarker,
})

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. To use this operation, you must have READ access to the bucket.

This action is not supported by Amazon S3 on Outposts.

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.

Parameter expectedBucketOwner : The account id of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error.

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 API 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 <isTruncated>true</isTruncated>. To return the additional keys, see key-marker and version-id-marker.

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 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,
  String? prefix,
  String? versionIdMarker,
}) async {
  ArgumentError.checkNotNull(bucket, 'bucket');
  final headers = <String, String>{
    if (expectedBucketOwner != null)
      'x-amz-expected-bucket-owner': expectedBucketOwner.toString(),
  };
  final $query = <String, List<String>>{
    if (delimiter != null) 'delimiter': [delimiter],
    if (encodingType != null) 'encoding-type': [encodingType.toValue()],
    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.send(
    method: 'GET',
    requestUri: '/${Uri.encodeComponent(bucket)}?versions',
    queryParams: $query,
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return ListObjectVersionsOutput.fromXml($result.body);
}