Java Requires Chilkat v11.0.0+
Chilkat2 Java
Backblaze S3 Delete Bucket Objects
See more Backblaze S3 Examples
Demonstrates how to delete objects in a bucket.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();
// keyID = Access Key ID or Access Key
http.setAwsAccessKey("access-key");
// applicationKey = Secret Access Key or Secret Key
http.setAwsSecretKey("secret-key");
// Region is the 2nd part of your S3 Endpoint
http.setAwsEndpoint("s3.us-west-002.backblazeb2.com");
String bucketName = "chilkat-test";
String objectName1 = "seahorse.jpg";
String objectName2 = "orchard.json";
StringTable st = new StringTable();
st.append(objectName1);
st.append(objectName2);
JsonObject jsonResp = new JsonObject();
try {
http.s3DeleteObjects(bucketName, st, jsonResp);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
System.out.println("Response status code = " + http.getLastStatus());
// Display the JSON response.
jsonResp.setEmitCompact(false);
System.out.println(jsonResp.emit());
}
}