listObjectsQuery method
list a batch of objects
Implementation
Future<ListObjectsOutput> listObjectsQuery(
String bucket,
String prefix,
String? marker,
String delimiter,
int? maxKeys,
) async {
MinioInvalidBucketNameError.check(bucket);
MinioInvalidPrefixError.check(prefix);
final queries = <String, dynamic>{};
queries['prefix'] = prefix;
queries['delimiter'] = delimiter;
if (marker != null) {
queries['marker'] = marker;
}
if (maxKeys != null) {
final keys = maxKeys >= 1000 ? 1000 : maxKeys;
queries['maxKeys'] = keys.toString();
}
final resp = await _client.request(
method: 'GET',
bucket: bucket,
queries: queries,
);
validate(resp);
final node = xml.XmlDocument.parse(resp.body);
final isTruncated = getNodeProp(node.rootElement, 'IsTruncated')!.innerText;
final nextMarker = getNodeProp(node.rootElement, 'NextMarker')?.innerText;
final objs = node.findAllElements('Contents').map((c) => Object.fromXml(c));
final prefixes = node
.findAllElements('CommonPrefixes')
.map((c) => CommonPrefix.fromXml(c));
return ListObjectsOutput()
..contents = objs.toList()
..commonPrefixes = prefixes.toList()
..isTruncated = isTruncated.toLowerCase() == 'true'
..nextMarker = nextMarker;
}