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

Unzip file in Apex?

Is there anyway to unzip a file in Apex?





Well I did some searching before replying to your post, I didn't come across any function or class in Apex which does that, but perhaps you can unzip a file using Javascript in case you want to include this functionality on a Visual Force page,one can call the Shell command equivalent in Javascript and you can run the exe of winzip and the file you wan to unzip as aparameter to the winzip.exe.

But then I realized  JavaScript has no file access whatsoever unless you run it via a standalone program such as Adobe Integrated Runtime rather than using a web browser. AIR provides add-ons to JavaScript which provide it with additional features such as file access which are not available from web pages.

So you know you can do it the round way upload the zipped file as a Static resource and then access its components , the Apex way, if all you want to do is get the file contents in the zipped file.


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.




No this is not possible.


What are you trying to do? Maybe there is another way.


Only solution is to send the file to a External service, unzip it, then send it back in to salesforce using Webservices API.

Pedro I Dal ColPedro I Dal Col
You can zip and unzip files natively in Apex using the Zippex library (open source)