How to virus scan a ZIP archive in Node.JS

Cloudmersive
1 min readFeb 27, 2020

--

Setting up virus scanning from scratch is obviously a huge amount of work. Don’t worry though, we have a handy little API for that.

To kick things off, we are going to use NPM install to implement our API client with the following command:

npm install cloudmersive-virus-api-client --save

With our API accessible, we just need to invoke scanFile and input a zip file:

var CloudmersiveVirusApiClient = require('cloudmersive-virus-api-client');var defaultClient = CloudmersiveVirusApiClient.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 CloudmersiveVirusApiClient.ScanApi();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.scanFile(inputFile, callback);

Done! Our scan result will be returned to us, including information about the potential threat.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet