Question

8
Replies
1019
Views
Terrance Krolak (TerranceK4053)
Stella

Stella
US
TerranceK4053 Member since 2018 49 posts
Stella
Posted: March 26, 2019
Last activity: April 9, 2019
Posted: 26 Mar 2019 9:24 EDT
Last activity: 9 Apr 2019 10:19 EDT
Closed

Unable to download file from Service Export directory

I generated a word document using pzGenerateDocument. The url that is returned seems to imply the file has been generated in the service export folder. I need to download this file to my desktop. How do I accomplish this? I tried using downloadFile function but it can't find the file. I also tried using straight java code to access the file but it cannot find the file either. I am told by pega cloud support that the file is there and has data in it as we are operating in the pega cloud. I've tried specifying the path a number of different ways neither of which I am able to find the file.


I generated a word document using pzGenerateDocument. The url that is returned seems to imply the file has been generated in the service export folder. I need to download this file to my desktop. How do I accomplish this? I tried using downloadFile function but it can't find the file. I also tried using straight java code to access the file but it cannot find the file either. I am told by pega cloud support that the file is there and has data in it as we are operating in the pega cloud. I've tried specifying the path a number of different ways neither of which I am able to find the file.

try{
url=com.pegarules.generated.pega_appdefinition_documentapp.pzGenerateDocument("BCBSMSFax1", tools, "NS-FW-MR-Work-RequestRecords", null);
}catch(Exception e)
{
oLog.error("Error in generating the document" + e.getMessage() + url);
}
String filePath = "file://web:/StaticContent/global/ServiceExport/" + pega_rules_string.whatComesAfterLast(url, '/');
// filePath = url;
// filePath = "BCBSMSFax1__1553292163416.docx​";
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.docx", false, null, true);
if (sErrorMessage != null){
tools.getThread().getThreadPage().putString("pyXMLStream", sErrorMessage);
}
//pega_rules_default.downloadFile(url, tools, false);

***Edited by Moderator Marissa to update platform capability tags; add SR Details****

System Administration Support Case Exists
Moderation Team has archived post, This thread is closed to future replies. Content and links will no longer be updated. If you have the same/similar Question, please write a new Question.