How to virus scan a Flash FLV or SWF in Python

Cloudmersive
2 min readMay 25, 2020

Security is, of course, one of the most important aspects of any endeavor. Let’s look at how to beef up our virus scanning without spending all day doing it. With some assistance from a handy Cloudmersive API, our setup will be complete in minutes, not hours.

Installing the client is the first order of business today.

pip install cloudmersive-virus-api-client

And now it’s just a matter of instancing the API, from which we will call scan_file, as you see demonstrated right here in this example:

from __future__ import print_functionimport timeimport cloudmersive_virus_api_clientfrom cloudmersive_virus_api_client.rest import ApiExceptionfrom pprint import pprint# Configure API key authorization: Apikeyconfiguration = cloudmersive_virus_api_client.Configuration()configuration.api_key['Apikey'] = 'YOUR_API_KEY'# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API classapi_instance = cloudmersive_virus_api_client.ScanApi(cloudmersive_virus_api_client.ApiClient(configuration))input_file = '/path/to/file' # file | Input file to perform the operation on.try:# Scan a file for virusesapi_response = api_instance.scan_file(input_file)pprint(api_response)except ApiException as e:print("Exception when calling ScanApi->scan_file: %s\n" % e)

Done! This API has over 17 million threat definitions, which are constantly updated via cloud. In addition, you can use scan_file_advanced for even more options, such as excluding specific file types and more.

Virus problem solved!

--

--

Cloudmersive

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