Hello All,
Good morning!. I have a requirement to
read a file content which streams the output in Octet-stream format through an REST-API call and to encode the received
response in encodedBase64 format as it needs to be sent to another system in upstream.
So I have implemented this and partly successful- which includes calling the
RESTAPI via Javascript using Apache HTTP client methods and I got the 200 response back and also I am able to encode the same in base64 format and pass it to the upstream system. The challenge i face here is when the file size streamed is of approximately anything above
13KB size and I get the below error
Internal Script error: java.io.IOException: chunked stream ended unexpectedly.
Note: The system which is streaming the file content can be of any type and any size. there is no upper limit set but in real time scenario it won't exceed 15-20 MB approx.
I tried 2 approaches till now. both of them are giving the same errors.
first approachvar output=op.getResponseBodyAsStream();
//to invoke the response bodyrd= new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(output));
// to buffer the read contents
response= Packages.org.apache.commons.io.IOUtils.toString(rd);
//finally collecting the responsesecond approachvar inputStream= op.getResponseBodyAsStream();
var outputStream= new Packages.org.apache.commons.io.output.ByteArrayOutputStream();
//instead of stream reader here i used bytearraystreamresponse= Packages.org.apache.commons.io.IOUtils.copy(inputStream,outputStream);
//finally copying the input to outputstreamI just highlighted the main piece of code where it is going wrong. Let me know if you need any other details . Please advise how to overcome this obstacle.
currently this needs to be implemented in
BPM7.5 Process designer but the runtime environment is in
BAW 19.0.0.3. I also tried the same logic in BAW 19.0.0.3 Web process designer thinking that
Apache library version could be a problem but there also I am getting the same error.
Regrads,
Bharanee
IBM BAW Developer
------------------------------
Bharaneedharan Muralidharan
IBM BAW Developer
------------------------------