Home > Back-end >  How to get S3 URL for the object from S3 bucket using aws-sdk-2.x
How to get S3 URL for the object from S3 bucket using aws-sdk-2.x

Time:01-05

We were using the AWS Java SDK-1.x version in our application till now. We decided to migrate to the 2.x. As per my analysis I have found out the equivalent function which we are using for 1.x client operation in 2.x in our application. But for some operation I could not able to find matching functions. Below are the details.

1.x (AmazonS3) 2.x (S3AsyncClient)
getObject(String bucket, String key) getObject(GetObjectRequest req, Path destination)
putObject(String bucket, String key, File file) putObject(PutObjectRequest req, Path source)
generatePresignedUrl(GeneratePresignedUrlRequest req) S3PreSigner.presignGetObject(GetObjectPresignRequest req)
deleteObject(String bucket, String key) deleteObject(DeleteObjectRequest req)
getUrl(String bucket, String key) ?
doesObjectExist(String bucket, String key) ?

Any help or pointer is really appreciated.

CodePudding user response:

Below are the replacements for the methods that you are looking for in 2.x SDK:

1.11.x Operation 2.0 Operation
getUrl S3Utilities#getUrl
doesObjectExist headObject

Here is a complete mapping of S3 1.x and 2.0 Operations.

  • Related