How to download multiple attachments as a zip file (Solved)

I have referenced the post https://support.pega.com/question/how-create-zip-archive-and-attach-case and created reusable functions to compress multiple files into a zip archive and download.

The function CreateZipFile takes pagelist, zip entry name property, zip entry contents property and generates zip byte array.

Another function downloadFile take bytearrary object and zip file name to download the file. Please see the attached document for the implementation.

How to download multiple files as a zip file_0.docx (417 KB)

@Satish I have go through your post , but could you please mention if this approach can be used for below scenario

I have a scenario in Pega where each Pega case have average 3-4 attachments each of 1 MB , i need to iterate through all the attachments and club them all to prepare one attachment or a zip file and allow the end-user to download the file , if i have to iterate through 100 cases then on an average 300-400 attachments i have to zip , this is going to impact the performance badly , how can i achieve this in Pega , the pega instance is running in On-premise environment