Native ZIP File Handling in Apex

Get Expert Salesforce, Traction Rec and Litify Support
What's New
Salesforce’s Spring ’25 Release introduced the new Compression namespace, allowing developers to create and extract ZIP files natively in Apex.
This capability is currently available in scratch orgs with the ZipSupportInApex feature enabled.
What This Means
Previously, in order to bundle attachments from Salesforce into a ZIP, developers would have to extract them, bundle them using an external service, and then reupload the zipped file back into Salesforce. This is now natively available through Apex.
The new compression support improves storage and transport efficiency, enabling developers to:
- Bundle multiple small files into a single compressed ZIP
- Improve data transfer times
- Simplify user downloads or imports within Salesforce.
Why is This Useful
This feature dramatically simplifies integration workflows where external systems expect or provide ZIP files.
Developers can now create and unpack ZIPs directly in Salesforce, eliminating the need for external services and improving performance.
Implementation Examples:
Attachment Download Button
Suppose you have a custom object Project__c that stores many related files — design documents, blueprints, images, and PDF reports.
Using the Compression namespace, you can create an Apex action that:
- Gathers all attachments or related ContentDocuments
- Compresses them into a single ZIP file
- Makes that ZIP available for download
This approach improves user experience (one-click download), reduces the number of file operations, and minimizes repetitive network calls.
External integration payload processing
An external system could be periodically sending ZIP files into your Salesforce org containing multiple CSV files, for example, product catalogs.
With native ZIP support:
- The ZIP file can be uploaded to Salesforce (e.g., via a custom API endpoint or file upload page).
- Apex can then extract the ZIP contents, identify each file type, and process them accordingly by inserting new records, updating existing ones, or attaching images.
This eliminates the need for an external tool just to unpack the files from the ZIP archive uploaded into Salesforce.
Conclusion
While native ZIP handling in Apex may look like a modest enhancement at first glance, it meaningfully improves how Salesforce manages files and overall user experience. By introducing the Compression namespace, Salesforce removes long-standing friction around zipping and unzipping files directly on the platform, unlocking cleaner, faster, and more maintainable solutions.
Beyond day‑to‑day use cases, this feature also opens the door to smarter file lifecycle management. For example, teams can implement scheduled Apex jobs that package older files into ZIP archives, export them to lower‑cost storage, and safely archive or remove the originals. The result is a more efficient, scalable approach to file handling that reduces technical debt while optimizing storage and operational costs.
Transform What’s Possible With
Salesforce
Traction Rec
Litify
Salesforce
Unlock the full potential of your platforms and make the impossible a reality with ECHO Technology Solutions.




