Zip Handling in Apex GA
Handling zip files directly in Apex has been a long-standing challenge due to CPU and heap limitations. Salesforce’s new native Zip Handling feature, now generally available in Spring '25, enables efficient processing of even large zip files on the platform with significantly lower heap usage and reasonable CPU times compared to previous methods like Zippex. Using simple Apex code with the Compression namespace, developers can extract zip entries seamlessly and monitor resource consumption easily. This opens up new possibilities for building scalable file-processing solutions entirely on platform without relying on external services or front-end extraction.
- Use Compression.ZipReader in Apex to process zip files natively on platform.
- Native zip handling consumes significantly less heap than third-party Apex libraries.
- You can safely process large zip files close to heap limits with short peak usage.
- Capture CPU and heap metrics to monitor resource usage during zip processing.
- Native support avoids asynchronous complexity and front-end security issues.
Image generated by ChatGPT 4o based on a prompt from Bob Buzzard Introduction Anyone who's developed custom solutions in Salesforce world is likely to have come up against the challenge of processing zip files. You could use a pure Apex solution, such as Zippex , leverage the Metadata API or push it all to the front end and use JavaScript . What these options all had in common was leaving you dissatisfied. Apex isn't the best language for CPU intensive activities like compression, so the maximum file size was relatively small. The metadata API isn't officially supported and introduces asynchronicity, while forcing the user to the front end simply to extract the contents of a file isn't the greatest experience and might introduce security risks. One year ago, in the Spring '24 release of Salesforce, we got the developer preview of Zip Handling in Apex which looked very cool.