Read AWS S3 Bucket using Mirth (AWS SDK 2.19 x version)
I see many are reaching out to me because they have issues on identifying the correct way to implement the s3 bucket reading option from the new AWS SDK method.
Here is what I have based on the new AWS S3 Bucket SDK, to read a object from the S3 Bucket using Mirth. Import all the necessary libraries needed for performing this activity
function getDataFromS3Bucket(bucketName,accessKey,secretKey,key){
var software = Packages.software;
var region = software.amazon.awssdk.regions.Region.US_EAST_1;
var credentialsProvider = software.amazon.awssdk.auth.credentials.StaticCredentialsProvider.create(software.amazon.awssdk.auth.credentials.AwsBasicCredentials.create(accessKey,secretKey));
var s3 = software.amazon.awssdk.services.s3.S3Client.builder().credentialsProvider(credentialsProvider).region(region).build();
var getRequest = software.amazon.awssdk.services.s3.model.GetObjectRequest.builder().bucket(bucketName).key(key).build();
var objectBytes = s3.getObjectAsBytes(getRequest);
var data = objectBytes.asByteArray();
var dataYouNeed= Packages.java.lang.String(data);
return dataYouNeed;
}