Andrii Sukhetskyi’s Post

The new Compression namespace for Apex, enabling the creation and extraction of ZIP files, is closer than ever ⏱️   It’s been almost a year since Salesforce announced the developer preview for "Compress and Extract ZIP Files in Apex", and we’re finally approaching the Salesforce Spring ’25, where it will become generally available. What’s new? A new namespace called "Compression", a "ZipReader" class for reading existing ZIP files (which you can retrieve from a callout response, for example), a "ZipWriter" class for creating ZIP files (and attaching them to an email, for example), and several other interesting methods along the way.   Now, speaking from the facts, those familiar with this problem know that for nearly 10 years, an amazing open-source library called "Zippex", developed by Pedro Dal Col and Pliny Smith, has allowed similar operations. Comparing this open source solution to the new "Compression" namespace, I have to admit that the new namespace delivers better performance, especially in terms of CPU time. Even with relatively large files, I didn’t notice significant drops. Although the heap size will remain an issue, as noted by Salesforce Product Management: "Apex isn't designed for processing large binary files, so the support will be limited to smaller filesize archives."   And a bit of salt in the wound, we have been on an almost 10-year journey for this feature, so I want to congratulate everyone on this anniversary and start a new countdown for the ability to add a password to ZIP files (which hasn’t been implemented). You can vote for it using the following link - https://lnkd.in/guJD8ps4

Check out a detailed overview of this namespace here: https://youtube.com/shorts/vBFm-CgG4ow

I wrote a detailed article on the performance and it is really fast. Funnily enough it's my least read article, so not a lot of people seem to care about zip performance 😅. I found it zips up to 24MB async in 114ms what should be enough for most use cases. I will add an upvote for the password, thanks for sharing! https://medium.com/@justusvandenberg/apex-zip-support-performance-test-03bef1539ed6

Thanks for sharing . This is really useful and hopefully can replace a very hacky LWC I built to download multiple files at once. If anyone has any recommendations for techniques to post files to an external site via Apex (including PDFs) I’d be really interested.

I think everyone who needed this in the last 2-4 years left the platform or divested anyway, or did in JS via some known workarounds. lol. EDIT: but congrats, I suppose!

Totally agree. Definitely adding password protection to the ZIP files would be more efficient , secured and provides data privacy as well.

See more comments

To view or add a comment, sign in

Explore content categories