removeObjects method

Future<void> removeObjects(
  1. String bucket,
  2. List<String> objects
)

Remove all the objects residing in the objectsList.

Implementation

Future<void> removeObjects(String bucket, List<String> objects) async {
  MinioInvalidBucketNameError.check(bucket);

  final bunches = groupList(objects, 1000);

  for (final bunch in bunches) {
    final payload = Delete(
      bunch.map((key) => ObjectIdentifier(key, null)).toList(),
      true,
    ).toXml().toString();

    final headers = {'Content-MD5': md5Base64(payload)};

    await _client.request(
      method: 'POST',
      bucket: bucket,
      resource: 'delete',
      headers: headers,
      payload: payload,
    );
  }
}