Skip to content

Instantly share code, notes, and snippets.

@mateusz-lisik
Last active January 3, 2016 14:00
Show Gist options
  • Save mateusz-lisik/4ef7152d3601fbee107c to your computer and use it in GitHub Desktop.
Save mateusz-lisik/4ef7152d3601fbee107c to your computer and use it in GitHub Desktop.
Modified Aws S3 client with custom support for checking if object exists in bucket
package it.lisik.kodeksy.uploader;
import com.amazonaws.auth.AWSCredentials;
public class AmazonS3Client extends com.amazonaws.services.s3.AmazonS3Client {
public AmazonS3Client() {
super();
}
public AmazonS3Client(AWSCredentials awsCredentials) {
super(awsCredentials);
}
public boolean doesObjectExistsInBucket(String bucketName, String objectName) {
return listObjects(bucketName).getObjectSummaries()
.stream()
.anyMatch(object -> object.getKey().equals(objectName));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment