function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shweta GargShweta Garg 

Making ZIP file in Apex

Hi All,

Our requirement is zipping multiple CSV files together and send the ZIP file to external system.For which We are using ZIPPEX open source library(https://github.com/pdalcol/Zippex)

Approach:
We are writing a batch program which will create CSV file and save it to documents.another batch will fetch CSV files from documents and zip them together.But It is causing CPU Limit exceeded or heap size exceeded for large file (say 5 MB).
Can you please suggest a workaround to do this  via apex?
Deepali KulshresthaDeepali Kulshrestha
Hi Shweta,

I was recently tasked with the challenge of creating ZIP files in Salesforce and saving them as attachments on records. In case you didn’t know, Salesforce doesn’t natively support doing this seemingly simple task within Apex. That means I was left to come up with a more clever solution…

The goal of this particular project was to create a number of XML files, then zip them up and attach the ZIP file to a record. The ZIP file would then be sent to a third-party service for processing. While this is a somewhat specific use case, there are a lot of other use cases where it might be necessary to create ZIP files in Salesforce.

Please refer the link regarding Salesforce Zip:

https://www.redargyle.com/blog/creating-zip-files-in-salesforce/

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha