+ Start a Discussion
Srikanta BiswalSrikanta Biswal 

how to download zip file from url and unzip that file in Apex ?

hi All,
I want to download a zip file from url and unzip that file.I got some code but that is not working.
Need some new code in apex to do this.
Thanks in advance
There is no native way to do this in Apex.  You may be able to do this with some hackery via the EncodingUtils but I highly doubt it.
Pedro I Dal ColPedro I Dal Col
You can use the Zippex library to do this. It is open source - you can download it here:

HttpRequest req = new HttpRequest();
req.setEndpoint('https://www.example.com/sample.zip'); //Zip file URL
HttpResponse response = new Http().send(req);
Blob zipFileBlob = response.getBodyAsBlob();
Zippex sampleZip = new Zippex(zipFileBlob);
Blob unzippedFileBlob = sampleZip.getFile('test1.txt'); //Name of file to unzip
String unzippedFileStr = unzippedFileBlob.toString();