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 (var upload in result.uploads) {
      final parts = listParts(bucket, upload.key!, upload.uploadId!);
      final size =
          await parts.fold(0, (dynamic acc, item) => acc + item.size);
      yield IncompleteUpload(upload: upload, size: size);
    }
    keyMarker = result.nextKeyMarker;
    uploadIdMarker = result.nextUploadIdMarker;
    isTruncated = result.isTruncated!;
  } while (isTruncated);
}