listIncompleteUploads method

Stream<IncompleteUpload> listIncompleteUploads(
  1. String bucket,
  2. String prefix, [
  3. bool recursive = false
])

Returns a stream that emits objects that are partially uploaded.

Implementation

Stream<IncompleteUpload> listIncompleteUploads(
  String bucket,
  String prefix, [
  bool recursive = false,
]) async* {
  MinioInvalidBucketNameError.check(bucket);
  MinioInvalidPrefixError.check(prefix);

  final delimiter = recursive ? '' : '/';

  String? keyMarker;
  String? uploadIdMarker;
  var isTruncated = false;

  do {
    final result = await listIncompleteUploadsQuery(
      bucket,
      prefix,
      keyMarker,
      uploadIdMarker,
      delimiter,
    );
    for (final upload in result.uploads) {
      final parts = listParts(bucket, upload.key!, upload.uploadId!);
      final size = await parts.fold<int>(
        0,
        (int acc, Part item) => acc + (item.size ?? 0),
      );
      yield IncompleteUpload(upload: upload, size: size);
    }
    keyMarker = result.nextKeyMarker;
    uploadIdMarker = result.nextUploadIdMarker;
    isTruncated = result.isTruncated!;
  } while (isTruncated);
}