web stats
AWS S3 Get Javascript Reader - Mirth Community

Go Back   Mirth Community > Mirth Connect > General Discussion

Reply
 
Thread Tools Display Modes
  #1  
Old 03-19-2019, 05: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

Code:
// 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
	}
}).toArray();

for (var i = 0; i < lines.length; i++) {
	logger.info('Text Line: ' + lines[i]);
	messages.add(new RawMessage(lines[i]));
}
s3ObjectInputStream.close();
return messages;
Reply With Quote
  #2  
Old 03-28-2019, 08:33 AM
giogiannola giogiannola is offline
What's HL7?
 
Join Date: May 2018
Posts: 3
giogiannola is on a distinguished road
Default

Great!! Thanks!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 03:18 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation