listObjectsV2 method
Returns all Objects in a bucket.
To list objects in a bucket with prefix, set prefix
to the desired prefix.
This uses ListObjectsV2 in the S3 API. For backward compatibility, use
listObjects instead.
Implementation
Stream<ListObjectsResult> listObjectsV2(
String bucket, {
String prefix = '',
bool recursive = false,
String? startAfter,
}) async* {
MinioInvalidBucketNameError.check(bucket);
MinioInvalidPrefixError.check(prefix);
final delimiter = recursive ? '' : '/';
bool? isTruncated = false;
String? continuationToken;
do {
final resp = await listObjectsV2Query(
bucket,
prefix,
continuationToken,
delimiter,
1000,
startAfter,
);
isTruncated = resp.isTruncated;
continuationToken = resp.nextContinuationToken;
yield ListObjectsResult(
objects: resp.contents!,
prefixes: resp.commonPrefixes.map((e) => e.prefix!).toList(),
);
} while (isTruncated!);
}