How to virus scan a RAR archive in Node.JS

Cloudmersive
1 min readFeb 28, 2020

--

Virus scanning is a crucial feature, but you probably don’t want to break the bank or waste an entire day coding it. We have a lovely compromise for you: one of our handy APIs.

First task, add this reference to your package.json file, so that our API client can be installed.

"dependencies": {
"cloudmersive-virus-api-client": "^1.1.3"
}

With that complete, all that we have left to do is call our scanFile function, shown below.

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);

Go ahead and test it out on your RAR file, and you will be alerted of any potential viruses or malware from a library of over 17 million definitions.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet