How to Get Content from PDF file placed in Shared path to stream into Pega

Hi,

We are trying with this code for Streaming into the browser. But its not working.

String filePath = tools.getParamValue(“FilePath”);

java.io.FileInputStream fileInputStream=null;

java.io.File file = new java.io.File(filePath);

byte bFile = new byte[(int) file.length()];

try {

fileInputStream = new java.io.FileInputStream(file);

fileInputStream.read(bFile);

fileInputStream.close();

}

catch(Exception e){

e.printStackTrace();

}

/* Change the name of the Test.docx to the actual file name that needs to be downloaded with extension.*/

String sErrorMessage = tools.sendFile(bFile, “Test.pdf”, false, null, false);

if (sErrorMessage != null){

tools.getThread().getThreadPage().putString(“pyXMLStream”, sErrorMessage);

}

Pega wont allow the external shared path, until its mounted.

We have used below code to achieve this functionality

String filePath = tools.getParamValue(“FilePath”);
String fileName = tools.getParamValue(“FileName”);

java.io.FileInputStream fileInputStream=null;

java.io.File file = new java.io.File(filePath);

byte bFile = new byte[(int) file.length()];

try{
java.io.FileInputStream fis = new java.io.FileInputStream(file);
fis.read(bFile);
fis.close();

}

catch(Exception e){

e.printStackTrace();

}

/* Change the name of the Test.docx to the actual file name that needs to be downloaded with extension.*/

String sErrorMessage = tools.sendFile(bFile, fileName, false, null, false);

if (sErrorMessage != null){

tools.getThread().getThreadPage().putString(“pyXMLStream”, sErrorMessage);

}