The S3 client in the AWS Java SDK ver 1 had a method to check for the existence of an object in a bucket
doesObjectExist(bucketName, objectName)
In version 2 of the SDK I don't see anything similar but I wanted to see if I was missing anything.
The only idea I had was to attempt to use
S3Client.getObject(GetObjectRequest)
which will throw a NoSuchKeyExcecption if the object doesn't exist. I hate to use an exception like this.
please see s3 client service changes - https://github.com/aws/aws-sdk-java-v2/blob/master/docs/LaunchChangelog.md#4-service-changes
headObject is the 2.0 equivalent operation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With