AnsweredAssumed Answered

How to read InputStream with Javascript Custom Scripting?

Question asked by danielhicks801432 on Jul 17, 2018
Latest reply on Jul 26, 2018 by danielhicks801432

Trying to use Javascript in Data Process Custom Scripting.  Found out how to access the Java classes via the compatibility script (thanks to Properties in Scripting Component ), but now I'm trying to read the incoming document (InputStream).

 

What's the best way to read the InputStream into a byte array or a string?


// Load compatibility script
load("nashorn:mozilla_compat.js");
// Import the com.boomi.execution.ExecutionUtil class
importClass(com.boomi.execution.ExecutionUtil);
importClass(java.util.Properties);
importClass(java.io.InputStream);

 

for( var i = 0; i < dataContext.getDataCount(); i++ ) {
  var is = dataContext.getStream(i);
  var props = dataContext.getProperties(i);

 

  // How to manipulate "is"?


  dataContext.storeStream('test', props);
}

Outcomes