Java Requires Chilkat v11.0.0+
Chilkat2 Java
S3 Delete Multiple Objects
See more Amazon S3 Examples
Demonstrates how to delete multiple objects in a single HTTP request.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.JsonObject;
import com.chilkatsoft.chilkat2.StringTable;
public class ChilkatExample {
public static void main(String[] args) {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Http http = new Http();
// Insert your access key here:
http.setAwsAccessKey("ABQXXABC83ABCDEFVQXX");
// Insert your secret key here:
http.setAwsSecretKey("XXXXYYYYabcdABCD12345678xxxxyyyyzzzz");
String bucketName = "chilkattestbucket";
String objectName1 = "starfish.jpg";
// Delete a particular version of this object:
String objectName2 = "conch.jpg; VersionId=\"3/L4kqtJlcpXroDTDmJ+rmSpXd3dIbrHY+MTRCxf3vjVBH40Nr8X8gdRQBpUMLUo\"";
String objectName3 = "seaUrchin.jpg";
StringTable st = new StringTable();
st.append(objectName1);
st.append(objectName2);
st.append(objectName3);
JsonObject jsonResp = new JsonObject();
try {
http.s3DeleteObjects(bucketName, st, jsonResp);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
// Display the JSON response.
jsonResp.setEmitCompact(false);
System.out.println(jsonResp.emit());
}
}