listObjects method

Stream<ListObjectsResult> listObjects(
  1. String bucket, {
  2. String prefix = '',
  3. bool recursive = false,
})

Returns all Objects in a bucket. To list objects in a bucket with prefix, set prefix to the desired prefix.

Implementation

Stream<ListObjectsResult> listObjects(
  String bucket, {
  String prefix = '',
  bool recursive = false,
}) async* {
  MinioInvalidBucketNameError.check(bucket);
  MinioInvalidPrefixError.check(prefix);
  final delimiter = recursive ? '' : '/';

  String? marker;
  var isTruncated = false;

  do {
    final resp = await listObjectsQuery(
      bucket,
      prefix,
      marker,
      delimiter,
      1000,
    );
    isTruncated = resp.isTruncated!;
    marker = resp.nextMarker;
    yield ListObjectsResult(
      objects: resp.contents!,
      prefixes: resp.commonPrefixes.map((e) => e.prefix!).toList(),
    );
  } while (isTruncated);
}