web stats
Mirth Community - View Single Post - AWS S3 Get Javascript Reader
View Single Post
Old 03-19-2019, 06:33 AM
nhunter nhunter is offline
What's HL7?
Join Date: Jan 2019
Posts: 1
nhunter is on a distinguished road
Default AWS S3 Get Javascript Reader

Hey guys, here is some quick code to retreive a file from an S3 bucket and inside of your Javascript reader. If you have any improvements feel free to share

// Set the AWS account Access Key, AWS account Secret Key
var awsCreds = new Packages.com.amazonaws.auth.BasicAWSCredentials(accessKey, secretKey);

// Set the s3client
var s3client = new Packages.com.amazonaws.services.s3.AmazonS3Client(awsCreds);

// Create s3Object
var s3Object = s3client.getObject(bucketName, keyName);

var s3ObjectInputStream = s3Object.getObjectContent();

var bReader = new BufferedReader(new InputStreamReader(s3ObjectInputStream));
var line;
var lines = bReader.lines().filter({
	test: function (x) {
		return x.length != 0

for (var i = 0; i < lines.length; i++) {
	logger.info('Text Line: ' + lines[i]);
	messages.add(new RawMessage(lines[i]));
return messages;
Reply With Quote