How to scan a file for viruses in Salesforce Apex

Need an advanced virus scanning solution for your Apex project? We’ve got you covered. Our API can provide you cloud-updated coverage with over 17 million definitions and counting. And the best part is, you will be up and running in just a few minutes.

Let’s get started by opening our project folder and extracting our API client into it.

Now we can proceed to call the scanFile function, as demonstrated below:

SwagScanApi api = new SwagScanApi();SwagClient client = api.getClient();// Configure API key authorization: ApikeyApiKeyAuth Apikey = (ApiKeyAuth) client.getAuthentication('Apikey');Apikey.setApiKey('YOUR API KEY');Map<String, Object> params = new Map<String, Object>{'inputFile' => Blob.valueOf('Sample text file\nContents')};try {// cross your fingersSwagVirusScanResult result = api.scanFile(params);System.debug(result);} catch (Swagger.ApiException e) {// ...handle your exceptions}

And then our result will be returned to us like so:

"CleanResult": true,
"FoundViruses": [
"FileName": "string",
"VirusName": "string"

Easy. No more virus scanning worries!

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store