How to extract Files and Folders from a Zip Archive in Node.JS

Having Zip extraction capabilities in your app or website can open up some excellent potential possibilities. What do you say I show you how to get this set up in no time flat?

With this dependency reference for package.json, we can install our API client, allowing us to continue on.

"dependencies": {
"cloudmersive-convert-api-client": "^2.1.6"

From there, we just need to call our zipArchiveZipExtract function:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveConvertApiClient.ZipArchiveApi();var inputFile = "/path/to/file"; // File | Input file to perform the operation on.var callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.zipArchiveZipExtract(inputFile, callback);

That’s really about it. The rest is pretty self-explanatory.

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.