Posted: 12 Aug 2019 17:06 EDT Last activity: 10 Sep 2019 14:23 EDT
Unzip a Zip File Attachment
I have a requirement to have the user attach a zip file to a case, unzip the file, and continue processing the unzipped files. I have created a Java function in Pega to unzip a file. It has 2 parameters, destDir (destination directory to store the unzip files, and zipFile. First I had zipFile as a String representing the path to the zip file, but I could not figure out how to get the file path from the attachment. We are using Alfresco for out CMIS document management. Then I tried passing the .pyAttachStream of the attachment file, which is a String. In my Java function, I then tried to create a Java File or FileOutputStream from this String. I keep getting an Exception of "File or Directory does not exist". I don't know if I am using a wrong directory path or if something else is wrong. I have attached my Java function, the Activity that calls it, and the error message.
I also have to read the unzipped files back in to another activity for further processing.
Another other approaches? I was hoping that .pyAttachStream would give me a java.io.FileInputStream or something that I could just pass to the Java function.
I have attached the CreateAttachmentFromZip activity.
This unzips my attached zip file, and creates new attachments on my Pega case. However, the XML file that is unzipped has extra blank lines throughout it, and the other unzipped files, which are like a PDF and image file I get "The attachment is not available."