How to Quarantine an Infected File in JavaScript
ZIP archives are known for their ability to condense a large amount of files, but did you know they can also be used to quarantine an infected file? All you’ll need to do is create a new ZIP archive for the dangerous content and apply encryption and password protection to it; the dangerous file will be effectively neutralized so it can’t infiltrate other applications or programs. Since this can be a complex process to achieve manually, we will demonstrate how you can perform the entire operation by using an API in JavaScript.
Let’s start by running this command to install jQuery:
bower install jquery
After the installation, we will call the function with the following example code:
var settings = {
"url": "https://api.cloudmersive.com/convert/archive/zip/create/quarantine",
"method": "POST",
"timeout": 0,
"headers": {
"password": "<string>",
"encryptionAlgorithm": "<string>",
"Content-Type": "application/x-www-form-urlencoded",
"Apikey": "YOUR-API-KEY-HERE"
},
"data": {
"inputFile1": "<binary>"
}
};$.ajax(settings).done(function (response) {
console.log(response);
});
This will ensure the safety of your other assets, while containing the malicious content. To retrieve your API key, head over to the Cloudmersive website to register for a free account; this provides 800 monthly calls across any of our APIs.