How to Scan a Google Cloud Platform Storage File in JavaScript

Google Cloud Platform (GCP) is Google’s cloud computing service offering, and while it’s newer to the market than Microsoft Azure or Amazon Web Services, it’s beginning to grow in popularity. In this quick tutorial, we will demonstrate how you can protect data you entrust to a GCP storage file by using a virus scanning API in JavaScript. This helpful tool will automatically scan the target file and any uploaded content for viruses, malware, trojans, ransomware, and spyware in less than a second.

To get things started, we will run this command to install jQuery:

bower install jquery

Now, we can call the virus scanning function with the following code:

var form = new FormData();
form.append("jsonCredentialFile", fileInput.files[0], "file");
var settings = {
"url": "",
"method": "POST",
"timeout": 0,
"headers": {
"bucketName": "<string>",
"objectName": "<string>",
"Content-Type": "multipart/form-data",
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
$.ajax(settings).done(function (response) {

The returned response will specify the virus name (if detected) or that your GCP file is out of harm’s way. To retrieve your API Key, visit the Cloudmersive website and register for a free account; this will provide access to 800 monthly calls across our portfolio of APIs.

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