Scan a File for Viruses in Python
Unfortunately, the precious data we store in our professional (or personal) databases each day can easily be infected with thousands of different forms of viruses, malware, trojans, ransomware, and more. It’s more important than ever to have high quality threat analysis of our data to avoid potentially catastrophic security breaches from within our own systems. With the Cloudmersive Virus Scan API, you can enable your application to scan files and content for viruses & leverage continuously updated signatures for millions of threats. Below, we’ll walk through connecting for a Python environment.
First, you’ll have to install the Python SDK by running the below command:
pip install cloudmersive-virus-api-client
Then, can copy in the callback function. It’ll ask for your API key in the second snippet, which you can easily acquire by making a free account on the Cloudmersive website.
from __future__ import print_function
import time
import cloudmersive_virus_api_client
from cloudmersive_virus_api_client.rest import ApiException
from pprint import pprint# Configure API key authorization: Apikey
configuration = cloudmersive_virus_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'# create an instance of the API class
api_instance = cloudmersive_virus_api_client.ScanApi(cloudmersive_virus_api_client.ApiClient(configuration))
input_file = '/path/to/inputfile' # file | Input file to perform the operation on.try:
# Scan a file for viruses
api_response = api_instance.scan_file(input_file)
pprint(api_response)
except ApiException as e:
print("Exception when calling ScanApi->scan_file: %s\n" % e)
If you use SharePoint Online, AWS S3 or Azure Blob storage, visit the Cloudmersive website to learn more about Storage Protect: a product which offers advanced control & customization of Virus Scan API security policies for those cloud databases.