AnsweredAssumed Answered

HCI: How to set Stage output stream in properties (need to suggest output filenames for streams)

Question asked by Chris Delezenski Employee on Jul 28, 2017
Latest reply on Aug 1, 2017 by Chris Delezenski

Hi Community....


I'm continuing to develop the OCR plugin for the Hornet project.


In order to "catch" the output stream and send a file to output, I need to give it a name.


Somewhere near the end of process(), I need to set the name of the outgoing suggested filename.


Here's a snippet from process():


DocumentBuilder docBuilder = this.callback.documentBuilder().copy(inputDocument);

File outputFile=null;

File inputFile=null;


InputStream uploadStream=null,resultStream=null;


String uri = inputDocument.getStringMetadataValue(StandardFields.URI);

inputFile=new File(uri.substring(6));

uploadStream=new FileInputStream(inputFile);

outputFile=new File(FilenameUtils.removeExtension(inputFile.getAbsolutePath())+".pdf");

resultStream=HttpPostContent(uploadStream, config.getProperty(PROPERTY_PDFCONVERTER.getName()).getValue());

//WRONG!  --- how do I set "HCI_output_filename" for the outgoing document stream?      

docBuilder.addMetadata("HCI_output_filename",                                        StringDocumentFieldValue.builder().setString(outputFile.getAbsoluteFile().getName()).build());

docBuilder.setStream("output", Collections.emptyMap(), resultStream);



Take an input stream from source (HCP? local filesystem?) and push it to microservice URL pointed to by PDFCONVERTER.  Catch the result stream and hand off to stage's output.