Last active
January 3, 2016 14:00
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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