Create a zip file with multiple files in Pega V851 and is password protected too

 One of my friends came with a requirement like- Is there anyway we can create a zip file with multiple files from Pega? Also, he asked me to protect the final zip file after finishing the process .After digging a bit in the net, I got an opensource (zip4j) since we don't find a direct OOTB feature for this usecase. This opensource was built by Srikanth Lingala and is based on pure java. There might be other opensources to create a zip file in the market but this one provides security on the final zip file. This opensource comes with a single jar file to import in Pega to get all necessary files to work on this exercise.

Here is the link to download the jar file: https://jar-download.com/artifacts/net.lingala.zip4j/zip4j/1.3.2/source-code 

As usual, I created a simple Pega function with the java code by importing the necessary packages in the library rule. Called this Pega function from a Data Transform and tried with 2 files and created a pwd protected zip file after running the DT. As a part of PoC work, kept all the files in my /tomcat/temp/Misc folder. Here is a sample screenshot for this exercise. The next steps for him could be like he needs to build the Pega UI to capture the files and start using this function from his env.

The below Pega function needs a parameter with ZipFileName and the return value is a string of Success/Fail. Logic is simple. Pass the files in parameters from the DT and construct the path in tomcat to create a zip file in the same path using the java code. All the steps are clearly documented in the code to implement independently. Feel free to contact me offline.


References:

1) Google.com
2) https://mvnrepository.com/
3) Pega Community Site
4) Pega Developers Hep







Popular posts from this blog

Connecting Claude to Pega Infinity 25.1.3 via MCP — Step-by-Step

itextpdf API to generate PDF doc from an image file using Pega PE

Understanding of Hugging Face platform for AI/ML platform