deleteMultipleObjects method
DELETE Multiple Objects 接口请求可以批量删除指定存储桶中的多个对象(Object),单次请求支持最多删除1000个对象
bucketName
region
delete
Implementation
Future<COSDeleteResult> deleteMultipleObjects({
String? bucketName,
String? region,
required COSDelete delete,
}) async {
Map<String, String> headers = <String, String>{};
final String xmlString = delete.toXmlString();
// http 框架设置body时,会自动给 Content-Type 指定字符集为 charset=utf-8
// 设置 application/xml; charset=utf-8 保持一致
headers['Content-Type'] = 'application/xml; charset=utf-8';
headers['Content-Length'] = xmlString.length.toString();
final String md5String = Base64Encoder()
.convert(md5.convert(xmlString.codeUnits).bytes)
.toString();
headers['Content-MD5'] = md5String;
final Response response = await client.post(
'${getBaseApiUrl(bucketName, region)}/?delete',
headers: headers,
body: xmlString,
);
return toXml<COSDeleteResult>(response)(COSDeleteResult.fromXml);
}