HttpDelete method = new HttpDelete(region.getStorageUrl(container, object));
this.execute(method, new DefaultResponseHandler());
}
public void deleteObjects(Region region, String container, List<String> objects) throws IOException {
HttpEntityEnclosingRequestBase method = new HttpEntityEnclosingRequestBase() {
@Override
public String getMethod() {
return "DELETE";
}
};
// Will delete multiple objects or containers from their account with a
// single request. Responds to DELETE requests with query parameter
// ?bulk-delete set.
LinkedList<NameValuePair> parameters = new LinkedList<NameValuePair>();
parameters.add(new BasicNameValuePair("bulk-delete", "1"));
method.setURI(region.getStorageUrl(container, parameters));
method.setHeader(HttpHeaders.CONTENT_TYPE, "text/plain");
// Newline separated list of url encoded objects to delete
StringBuilder body = new StringBuilder();
for(String object : objects) {
final String path = region.getStorageUrl(container, object).getRawPath();
body.append(path.substring(region.getStorageUrl().getRawPath().length() + 1)).append('\n');
}
method.setEntity(new StringEntity(body.toString(), "UTF-8"));
this.execute(method, new DefaultResponseHandler());
}