How to virus scan a DMG archive in Node.JS
1 min readFeb 28, 2020
You need an easy way to implement virus scanning in Node.JS. We have the perfect solution for you, both simple and quick. Let’s take a look at how it works.
Begin by using NPM install to install our API client.
npm install cloudmersive-virus-api-client --save
Wait for the installation to finish, then proceed to implement scanFile, like so:
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);
And we are already set up. Any inputFile will be scanned; we will then be provided with information about threats, if any.