You need to sign in to do that
Don't have an account?

How to create an Zip file with APEX
I want to create an zip file with APEX, my requirement is to extract all the documents related to an object and archive it as a zip file.
Files could be images, text, word or CSV etc.
I have tried this Link - https://github.com/pdalcol/Zippex, but it gives me a APEX CPU Limit exceeded error when I try to compress multiple files at once.
Please provide information or tell another way to solve this error using APEX?
Files could be images, text, word or CSV etc.
I have tried this Link - https://github.com/pdalcol/Zippex, but it gives me a APEX CPU Limit exceeded error when I try to compress multiple files at once.
Please provide information or tell another way to solve this error using APEX?
Can you try checking the below link:
>> https://salesforcescool.blogspot.com/2018/11/create-zip-of-salesforce-attachment.html
Do let me know if this works.
Regards,
Anutej
Salesforce doesn't provide zip support out of the box but you can use Zippex which is an open-source zip library for Apex. https://github.com/pdalcol/Zippex
And in the apex we will simply do ,
If this answer helps you, please mark it as accepted.
Regards,
Tushar Sharma
https://newstechnologystuff.com/
Hi Tushar,
Yes,right. I have used the zippex library and its actually working but the problem occures when I try to compress multiple files at once or we can say its the size limit is there. So that time i get the APEX CPU Time limit error.
If you have any idea about the file size limit that we can compress?
Thanks,
Khushbu
I am not quite sure but based on heap size (6 MB Sync) file size should be lesser than that. It also depends on other variables. You can use the LIMIT class to get these details. its a hit and run situation.
If this answer helps you, please mark it as accepted.
Regards,
Tushar Sharma
https://newstechnologystuff.com/
If you got the solution of this problem , please share with us
i'm also suffering from this problem.
Thanks & Regards
Jitendra Singh
Email Id - jitendrasingh1304082@gmail.com
https://filezipo.io/zip-files/
I've used the jsZip library with success in the past to offload the zipping to the browser and avoiding Apex limitations.
https://stuk.github.io/jszip/