Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS SDK Java version 2 - is there an equivalent to doesObjectExist() from ver 1?

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.

like image 751
menapole Avatar asked Aug 26 '19 18:08

menapole


1 Answers

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

like image 110
Suriyakanth Avatar answered Sep 21 '22 14:09

Suriyakanth