listObjects method
Implementation
Future<List<String>> listObjects({String? prefix, int maxKeys = 1000}) async {
try {
final queryParams = <String, String>{'list-type': '2', 'max-keys': maxKeys.toString()};
if (prefix != null) {
queryParams['prefix'] = prefix;
}
final response = await _makeRequest(method: 'GET', path: '/', queryParams: queryParams);
if (response.statusCode == 200) {
final xml = utf8.decode(response.body);
final keys = <String>[];
final regex = RegExp(r'<Key>(.*?)</Key>');
for (final match in regex.allMatches(xml)) {
keys.add(match.group(1)!);
}
return keys;
} else {
return [];
}
} catch (e) {
return [];
}
}