这是我的代码:
try {
DeleteObjectsResult delObjRes = s3Client
.deleteObjects(multiObjectDeleteRequest);
System.out.format("Successfully deleted all the %s items.\n", delObjRes
.getDeletedObjects().size());
} catch (MultiObjectDeleteException e) {
System.out.format("%s \n", e.getMessage());
System.out.format("No. of objects successfully deleted = %s\n", e
.getDeletedObjects().size());
System.out.format("No. of objects failed to delete = %s\n", e.getErrors()
.size());
System.out.format("Printing error data...\n");
for (DeleteError deleteError : e.getErrors()) {
System.out.format("Object Key: %s\t%s\t%s\n", deleteError.getKey(),
deleteError.getCode(), deleteError.getMessage());
}
}
例外情况如下:
Exception in thread "main" Status Code: 400, AWS Service: Amazon S3, AWS Request ID: 3EB96BFE84959731, AWS Error Code: MalformedXML, AWS Error Message: The XML you provided was not well-formed or did not validate against our published schema, S3 Extended Request ID: pE+pEHF36KqItpx1y6tJe6m50lTD1C/YHe0bVOmJW5TRBV7EfxvS5+Dc6JKX5AYb
at
com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:556)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:289)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:170)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:2648)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:2620)
at com.amazonaws.services.s3.AmazonS3Client.deleteObjects(AmazonS3Client.java:1363)
at com.neem23.cleanup.CleanUp.deleteMultipleObjects(CleanUp.java:73)
at com.neem23.cleanup.StartCleanUp.main(StartCleanUp.java:50)