Skip to content

Instantly share code, notes, and snippets.

@stephen-maina
Created April 12, 2015 14:38
Show Gist options
  • Save stephen-maina/d37b5ca8a0dd698981be to your computer and use it in GitHub Desktop.
Save stephen-maina/d37b5ca8a0dd698981be to your computer and use it in GitHub Desktop.
AWS Delete File
public void deleteAWS(String link) throws IOException {
AmazonS3 s3Conn = new AmazonS3Client(
new PropertiesCredentials(
Document.class
.getResourceAsStream("/com/api/AwsCredentials.properties")));
DeleteObjectsRequest multiDelete = new DeleteObjectsRequest(
"schoolmart-document");
List<KeyVersion> keys = new ArrayList<DeleteObjectsRequest.KeyVersion>();
keys.add(new KeyVersion(link.replace(
"http://s3.amazonaws.com/doc-document/", "")));
multiDelete.setKeys(keys);
s3Conn.deleteObjects(multiDelete);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment