Scan File For Virus using Net Core

Scan File For Virus using Net Core

SharpAPIs provide you with a convenient API to scan you files of any size for viruses and any possible malware. In this topic we are going to show you how to Scan File For Virus using Net Core. We are going to use the following file as our input file:

https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx

First we start a conversion job by making a POST request to the following URL and include these conversion parameters into your request: inputFile and async

Request parameter descriptions (for the full and detailed description, please click here):

X-ApplicationID Your application ID (which you get from your Doc Conversion API Account)
X-SecretKey Your secret key  (which you get from your Doc Conversion API Account)
inputFile The file you would like to scan or a URL
async Defines if the request should be sync or async

Scan File For Virus using cURL

Scanning URL

https://api.virusscannerapi.com/virusscan

URL Virus Scanning Example
class Program
    {
        static void Main(string[] args)
        {
            using (HttpClient client = new HttpClient())
            {
                // Adding authentication headers
                client.DefaultRequestHeaders.Add("X-ApplicationID", "Get your key from https://app.docconversionapi.com/#/applications");
                client.DefaultRequestHeaders.Add("X-SecretKey", "Get your key from https://app.docconversionapi.com/#/applications");

                var inputFileUrl = "https://www.docconversionapi.com/samples/example.docx";

                using (var requestContent = new MultipartFormDataContent(
                    "Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture)
                    ))
                {
                    // Setting body parameters
                    requestContent.Add(new StringContent(inputFileUrl), "inputFile");
                    requestContent.Add(new StringContent("false"), "async");

                    // Sending a POST request to DCA API
                    using (var requestResultTask = client.PostAsync(
                        "https://api.virusscannerapi.com/virusscan", requestContent
                    ))
                    {
                        var requestResult = requestResultTask.Result;

                        if (requestResult.IsSuccessStatusCode)
                        {
                            Console.WriteLine([email protected]"This is a response JSON object where you can find fileDownloadUrl: {requestResult.Content.ReadAsStringAsync().Result}");
                        }
                        else
                        {
                            Console.WriteLine($"Error has occured! {requestResult.Content.ReadAsStringAsync().Result}");
                            Console.ReadKey();
                        }
                    }
                }
            }
        }
    }
Local File Virus Scanning Example
class Program
    {
        static void Main(string[] args)
        {
            using (HttpClient client = new HttpClient())
            {
                // Adding authentication headers
                client.DefaultRequestHeaders.Add("X-ApplicationID", "Get your key from https://app.docconversionapi.com/#/applications");
                client.DefaultRequestHeaders.Add("X-SecretKey", "Get your key from https://app.docconversionapi.com/#/applications");

                var inputFileUrl = "https://www.docconversionapi.com/samples/example.docx";

                using (var requestContent = new MultipartFormDataContent(
                    "Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture)
                    ))
                {
                    // Setting body parameters
                    requestContent.Add(new StringContent(inputFileUrl), "inputFile");
                    requestContent.Add(new StringContent("false"), "async");

                    // Sending a POST request to DCA API
                    using (var requestResultTask = client.PostAsync(
                        "https://api.virusscannerapi.com/virusscan", requestContent
                    ))
                    {
                        var requestResult = requestResultTask.Result;

                        if (requestResult.IsSuccessStatusCode)
                        {
                            Console.WriteLine([email protected]"This is a response JSON object where you can find fileDownloadUrl: {requestResult.Content.ReadAsStringAsync().Result}");
                        }
                        else
                        {
                            Console.WriteLine($"Error has occured! {requestResult.Content.ReadAsStringAsync().Result}");
                            Console.ReadKey();
                        }
                    }
                }
            }
        }
    }

After the scanning job has finished processing your file, you will get a response like the following:

{
    "id": 0,
    "userId": null,
    "fileName": "https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx",
    "startedAt": "2020-03-25T12:16:55.0340019+00:00",
    "finishedAt": "2020-03-25T12:16:55.2484882+00:00",
    "status": "File is clean",
    "userIpAddress": "172.96.111.111"
}

If you have decided to make an async request instead of sync then your response will have the same structure but will not contain information like finishedAt etc.

To get your scanning result you will need to send a GET request to the following URL and use the previously returned ID of your scanning job.
https://api.virusscannerapi.com/virusscan/{{id}}

If you have any questions or need any further help, please contact us at [email protected].

Scan File For Virus using Ruby

Scan File For Virus using Ruby

SharpAPIs provide you with a convenient API to scan you files of any size for viruses and any possible malware. In this topic we are going to show you how to Scan File For Virus using Ruby. We are going to use the following file as our input file:

https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx

First we start a conversion job by making a POST request to the following URL and include these conversion parameters into your request: inputFile and async

Request parameter descriptions (for the full and detailed description, please click here):

X-ApplicationID Your application ID (which you get from your Doc Conversion API Account)
X-SecretKey Your secret key  (which you get from your Doc Conversion API Account)
inputFile The file you would like to scan or a URL
async Defines if the request should be sync or async

Scan File For Virus using cURL

Scanning URL

https://api.virusscannerapi.com/virusscan

URL Virus Scanning Example
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

uri = URI.parse("https://api.virusscannerapi.com/virusscan")

headers = { 
    'X-ApplicationID': 'Get your key from https://app.docconversionapi.com/#/applications',
    'X-SecretKey': 'Get your key from https://app.docconversionapi.com/#/applications'
}
form_data = {
    "inputFile" => "https://www.docconversionapi.com/samples/example.docx",
    "async" => "false"
}

# Create the HTTP objects
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
request = Net::HTTP::Post.new(uri.path, headers)
request.set_form form_data, 'multipart/form-data'

# Send the request
response = https.request(request)
puts response.body
Local File Virus Scanning Example
require 'net/http'
require 'net/https'
require 'uri'
require 'json'
require 'net/http/post/multipart'

uri = URI.parse("https://api.virusscannerapi.com/virusscan")

File.open("example.docx") do |inputFile|

form_data = {
    "inputFile" => UploadIO.new(inputFile, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "example.docx"),
    "async" => "false"
}

# Create the HTTP objects
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
request = Net::HTTP::Post::Multipart.new(uri.path, form_data)
request.add_field('X-ApplicationID', 'Get your key from https://app.docconversionapi.com/#/applications')
request.add_field('X-SecretKey', 'Get your key from https://app.docconversionapi.com/#/applications')

# Send the request
response = https.request(request)
puts response.body
end

After the scanning job has finished processing your file, you will get a response like the following:

{
    "id": 0,
    "userId": null,
    "fileName": "https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx",
    "startedAt": "2020-03-25T12:16:55.0340019+00:00",
    "finishedAt": "2020-03-25T12:16:55.2484882+00:00",
    "status": "File is clean",
    "userIpAddress": "172.96.111.111"
}

If you have decided to make an async request instead of sync then your response will have the same structure but will not contain information like finishedAt etc.

To get your scanning result you will need to send a GET request to the following URL and use the previously returned ID of your scanning job.
https://api.virusscannerapi.com/virusscan/{{id}}

If you have any questions or need any further help, please contact us at [email protected].

Scan File For Virus using Python

Scan File For Virus using Python

SharpAPIs provide you with a convenient API to scan you files of any size for viruses and any possible malware. In this topic we are going to show you how to Scan File For Virus using Python. We are going to use the following file as our input file:

https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx

First we start a conversion job by making a POST request to the following URL and include these conversion parameters into your request: inputFile and async

Request parameter descriptions (for the full and detailed description, please click here):

X-ApplicationID Your application ID (which you get from your Doc Conversion API Account)
X-SecretKey Your secret key  (which you get from your Doc Conversion API Account)
inputFile The file you would like to scan or a URL
async Defines if the request should be sync or async

Scan File For Virus using cURL

Scanning URL

https://api.virusscannerapi.com/virusscan

URL Virus Scanning Example
import requests

endpoint = "https://api.virusscannerapi.com/virusscan"
headers = {
    'X-ApplicationID': 'Get your key from https://app.docconversionapi.com/#/applications',
    'X-SecretKey': 'Get your key from https://app.docconversionapi.com/#/applications'
}
data = {
    'inputFile': 'https://www.docconversionapi.com/samples/example.docx',
    'async': 'false',
}

r = requests.post(url = endpoint, data = data, headers = headers)

response = r.text
print(response)
Local File Virus Scanning Example
import requests
import io

endpoint = "https://api.virusscannerapi.com/virusscan"
headers = {
    'X-ApplicationID': 'Get your key from https://app.docconversionapi.com/#/applications',
    'X-SecretKey': 'Get your key from https://app.docconversionapi.com/#/applications'
}
file = open("example.html", "rb")
data = {
    'async': 'false',
}
files = {
    'inputFile': ('example.docx', file.read())
}

r = requests.post(url=endpoint, data=data, headers=headers, files = files)

response = r.text
print(response)

After the scanning job has finished processing your file, you will get a response like the following:

{
    "id": 0,
    "userId": null,
    "fileName": "https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx",
    "startedAt": "2020-03-25T12:16:55.0340019+00:00",
    "finishedAt": "2020-03-25T12:16:55.2484882+00:00",
    "status": "File is clean",
    "userIpAddress": "172.96.111.111"
}

If you have decided to make an async request instead of sync then your response will have the same structure but will not contain information like finishedAt etc.

To get your scanning result you will need to send a GET request to the following URL and use the previously returned ID of your scanning job.
https://api.virusscannerapi.com/virusscan/{{id}}

If you have any questions or need any further help, please contact us at [email protected].

Scan File For Virus using PHP

Scan File For Virus using PHP

SharpAPIs provide you with a convenient API to scan you files of any size for viruses and any possible malware. In this topic we are going to show you how to Scan File For Virus using PHP. We are going to use the following file as our input file:

https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx

First we start a conversion job by making a POST request to the following URL and include these conversion parameters into your request: inputFile and async

Request parameter descriptions (for the full and detailed description, please click here):

X-ApplicationID Your application ID (which you get from your Doc Conversion API Account)
X-SecretKey Your secret key  (which you get from your Doc Conversion API Account)
inputFile The file you would like to scan or a URL
async Defines if the request should be sync or async

Scan File For Virus using cURL

Scanning URL

https://api.virusscannerapi.com/virusscan

URL Virus Scanning Example
<?php
$url = 'https://api.virusscannerapi.com/virusscan';
$fields = array(
    'inputFile' => 'https://www.docconversionapi.com/samples/example.docx',
    'async' => 'false'
);

//url-ify the data for the POST
foreach ($fields as $key => $value) {
    $fields_string .= $key . '=' . $value . '&';
}
$fields_string = rtrim($fields_string, '&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'X-ApplicationID: Get your key from https://app.docconversionapi.com/#/applications',
    'X-SecretKey: Get your key from https://app.docconversionapi.com/#/applications'
));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);

//execute post
$result = curl_exec($ch);
print $result;
Local File Virus Scanning Example
curl -H "Content-Type: multipart/form-data" -H "X-ApplicationID: Get your key from https://app.docconversionapi.com/#/applications" -H "X-SecretKey: Get your key from https://app.docconversionapi.com/#/applications" -F "async=false" -F "[email protected]" -X POST "https://api.virusscannerapi.com/virusscan"

After the scanning job has finished processing your file, you will get a response like the following:

<?php
$url = 'https://api.virusscannerapi.com/virusscan';
$fields = array(
    'inputFile' => file_get_contents('example.docx'),
    'async' => 'false'
);

//url-ify the data for the POST
foreach ($fields as $key => $value) {
    $fields_string .= $key . '=' . $value . '&';
}
$fields_string = rtrim($fields_string, '&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'X-ApplicationID: Get your key from https://app.docconversionapi.com/#/applications',
    'X-SecretKey: Get your key from https://app.docconversionapi.com/#/applications'
));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);

//execute post
$result = curl_exec($ch);
print $result;

If you have decided to make an async request instead of sync then your response will have the same structure but will not contain information like finishedAt etc.

To get your scanning result you will need to send a GET request to the following URL and use the previously returned ID of your scanning job.
https://api.virusscannerapi.com/virusscan/{{id}}

If you have any questions or need any further help, please contact us at [email protected].

Scan File For Virus using NodeJS

Scan File For Virus using NodeJS

SharpAPIs provide you with a convenient API to scan you files of any size for viruses and any possible malware. In this topic we are going to show you how to Scan File For Virus using NodeJS. We are going to use the following file as our input file:

https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx

First we start a conversion job by making a POST request to the following URL and include these conversion parameters into your request: inputFile and async

Request parameter descriptions (for the full and detailed description, please click here):

X-ApplicationID Your application ID (which you get from your Doc Conversion API Account)
X-SecretKey Your secret key  (which you get from your Doc Conversion API Account)
inputFile The file you would like to scan or a URL
async Defines if the request should be sync or async

Scan File For Virus using cURL

Scanning URL

https://api.virusscannerapi.com/virusscan

URL Virus Scanning Example
var request = require('request'),
    fs = require('fs'),
    https = require('https'),
    formData = {
    };


// Adding authentication headers
var headers = {
    'X-ApplicationID': 'Get your key from https://app.docconversionapi.com/#/applications',
    'X-SecretKey': 'Get your key from https://app.docconversionapi.com/#/applications'
};

// Result of this request is a JSON object which contains information about conversion
// including fileDownloadUrl that is used to get the resulting file
var conversionRequest = request.post({
    url: 'https://api.virusscannerapi.com/virusscan',
    formData: formData,
    rejectUnauthorized: false,
    headers: headers,
    encoding: 'binary'
}, function (err, response) {
    
    var responseParsed = null;

    if (response.statusCode == 200) {

        // Parsing response JSON object and getting fileDownloadUrl value
        responseParsed = JSON.parse(response.body);
        console.log(responseParsed.fileDownloadUrl);

        // Downloading the file and writing it to the local folder
        const resultFile = fs.createWriteStream('output.pdf');
        https.get(responseParsed.fileDownloadUrl, function (response) {
            response.pipe(resultFile);
        });
    }
});

// Adding all parameters to multipart form
var form = conversionRequest.form();
form.append("inputFile", "https://www.docconversionapi.com/samples/example.docx");
form.append("async", "false");
Local File Virus Scanning Example
var request = require('request'),
    fs = require('fs'),
    https = require('https'),
    formData = {
    };


// Adding authentication headers
var headers = {
    'X-ApplicationID': 'Get your key from https://app.docconversionapi.com/#/applications',
    'X-SecretKey': 'Get your key from https://app.docconversionapi.com/#/applications'
};

// Result of this request is a JSON object which contains information about conversion
// including fileDownloadUrl that is used to get the resulting file
var conversionRequest = request.post({
    url: 'https://api.virusscannerapi.com/virusscan',
    formData: formData,
    rejectUnauthorized: false,
    headers: headers,
    encoding: 'binary'
}, function (err, response) {
    
    var responseParsed = null;

    if (response.statusCode == 200) {

        // Parsing response JSON object and getting fileDownloadUrl value
        responseParsed = JSON.parse(response.body);
        console.log(responseParsed.fileDownloadUrl);

        // Downloading the file and writing it to the local folder
        const resultFile = fs.createWriteStream('output.pdf');
        https.get(responseParsed.fileDownloadUrl, function (response) {
            response.pipe(resultFile);
        });
    }
});

// Adding all parameters to multipart form
var form = conversionRequest.form();
form.append("inputFile", fs.readFileSync('example.docx'), "example.docx");
form.append("async", "false");

After the scanning job has finished processing your file, you will get a response like the following:

{
    "id": 0,
    "userId": null,
    "fileName": "https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx",
    "startedAt": "2020-03-25T12:16:55.0340019+00:00",
    "finishedAt": "2020-03-25T12:16:55.2484882+00:00",
    "status": "File is clean",
    "userIpAddress": "172.96.111.111"
}

If you have decided to make an async request instead of sync then your response will have the same structure but will not contain information like finishedAt etc.

To get your scanning result you will need to send a GET request to the following URL and use the previously returned ID of your scanning job.
https://api.virusscannerapi.com/virusscan/{{id}}

If you have any questions or need any further help, please contact us at [email protected].

Scan File For Virus using jQuery

Scan File For Virus using jQuery

SharpAPIs provide you with a convenient API to scan you files of any size for viruses and any possible malware. In this topic we are going to show you how to Scan File For Virus using jQuery. We are going to use the following file as our input file:

https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx

First we start a conversion job by making a POST request to the following URL and include these conversion parameters into your request: inputFile and async

Request parameter descriptions (for the full and detailed description, please click here):

X-ApplicationID Your application ID (which you get from your Doc Conversion API Account)
X-SecretKey Your secret key  (which you get from your Doc Conversion API Account)
inputFile The file you would like to scan or a URL
async Defines if the request should be sync or async

Scan File For Virus using cURL

Scanning URL

https://api.virusscannerapi.com/virusscan

URL Virus Scanning Example
function sendPost() {
    var formData = new FormData();

    //Adding required parameters
    formData.append("inputFile", "http://test2.travelitinerary.net/wordtest2.cfm/?UUID=83D177DA-D374-4B04-BA6E-EB3772E937E3&PageSize=A4");
    formData.append("async", "false");

    var request = new XMLHttpRequest();
    request.open('POST', 'https://api.virusscannerapi.com/virusscan', true);
    request.responseType = 'json';

    //Please, paste your AppId and SecretKey values here
    request.setRequestHeader("X-ApplicationID", 'Get your key from https://app.docconversionapi.com/#/applications');
    request.setRequestHeader("X-SecretKey", 'Get your key from https://app.docconversionapi.com/#/applications');

    request.onload = function () {
        if (request.status == 200) {
            console.log(request.response);
        }
    }

    request.send(formData);
}
Local File Virus Scanning Example
function sendPost() {
    var formData = new FormData();
    var inputFile = document.getElementById('fileInput').files[0];

    //Adding required parameters
    formData.append("inputFile", inputFile);
    formData.append("async", "false");

    var request = new XMLHttpRequest();
    request.open('POST', 'https://api.virusscannerapi.com/virusscan', true);
    request.responseType = 'json';

    //Please, paste your AppId and SecretKey values here
    request.setRequestHeader("X-ApplicationID", 'Get your key from https://app.docconversionapi.com/#/applications');
    request.setRequestHeader("X-SecretKey", 'Get your key from https://app.docconversionapi.com/#/applications');

    request.onload = function () {
        if (request.status == 200) {
            console.log(request.response);
        }
    }

    request.send(formData);
}

After the scanning job has finished processing your file, you will get a response like the following:

{
    "id": 0,
    "userId": null,
    "fileName": "https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx",
    "startedAt": "2020-03-25T12:16:55.0340019+00:00",
    "finishedAt": "2020-03-25T12:16:55.2484882+00:00",
    "status": "File is clean",
    "userIpAddress": "172.96.111.111"
}

If you have decided to make an async request instead of sync then your response will have the same structure but will not contain information like finishedAt etc.

To get your scanning result you will need to send a GET request to the following URL and use the previously returned ID of your scanning job.
https://api.virusscannerapi.com/virusscan/{{id}}

If you have any questions or need any further help, please contact us at [email protected].

Scan File For Virus using Java

Scan File For Virus using Java

SharpAPIs provide you with a convenient API to scan you files of any size for viruses and any possible malware. In this topic we are going to show you how to Scan File For Virus using Java. We are going to use the following file as our input file:

https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx

First we start a conversion job by making a POST request to the following URL and include these conversion parameters into your request: inputFile and async

Request parameter descriptions (for the full and detailed description, please click here):

X-ApplicationID Your application ID (which you get from your Doc Conversion API Account)
X-SecretKey Your secret key  (which you get from your Doc Conversion API Account)
inputFile The file you would like to scan or a URL
async Defines if the request should be sync or async

Scan File For Virus using Java

Scanning URL

https://api.virusscannerapi.com/virusscan

URL Virus Scanning Example
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

public class App 
{
    public static void main( String[] args )
    {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("https://api.virusscannerapi.com/virusscan");

        httppost.addHeader("X-ApplicationID", "Get your key from https://app.docconversionapi.com/#/applications");
        httppost.addHeader("X-SecretKey", "Get your key from https://app.docconversionapi.com/#/applications");

        MultipartEntity reqEntity = new MultipartEntity();
        reqEntity.addPart("async", new StringBody("false"));
        reqEntity.addPart("inputFile", "https://www.docconversionapi.com/samples/example.docx");

        httppost.setEntity(reqEntity);

        HttpResponse response = httpclient.execute(httppost);
        System.out.println(response);

        HttpEntity resEntity = response.getEntity();
        System.out.println(resEntity);
        System.out.println(EntityUtils.toString(resEntity));

        EntityUtils.consume(resEntity);
        httpclient.getConnectionManager().shutdown();
    }
}
Local File Virus Scanning Example
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

public class App 
{
    public static void main( String[] args )
    {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("https://api.virusscannerapi.com/virusscan");

        httppost.addHeader("X-ApplicationID", "Get your key from https://app.docconversionapi.com/#/applications");
        httppost.addHeader("X-SecretKey", "Get your key from https://app.docconversionapi.com/#/applications");

        File fileToUse = new File("example.docx");
        FileBody data = new FileBody(fileToUse);

        MultipartEntity reqEntity = new MultipartEntity();
        reqEntity.addPart("async", new StringBody("false"));
        reqEntity.addPart("inputFile", data, "example.docx");

        httppost.setEntity(reqEntity);

        HttpResponse response = httpclient.execute(httppost);
        System.out.println(response);

        HttpEntity resEntity = response.getEntity();
        System.out.println(resEntity);
        System.out.println(EntityUtils.toString(resEntity));

        EntityUtils.consume(resEntity);
        httpclient.getConnectionManager().shutdown();
    }
}

 

After the scanning job has finished processing your file, you will get a response like the following:

{
    "id": 0,
    "userId": null,
    "fileName": "https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx",
    "startedAt": "2020-03-25T12:16:55.0340019+00:00",
    "finishedAt": "2020-03-25T12:16:55.2484882+00:00",
    "status": "File is clean",
    "userIpAddress": "172.96.111.111"
}

If you have decided to make an async request instead of sync then your response will have the same structure but will not contain information like finishedAt etc.

To get your scanning result you will need to send a GET request to the following URL and use the previously returned ID of your scanning job.
https://api.virusscannerapi.com/virusscan/{{id}}

If you have any questions or need any further help, please contact us at [email protected].

Scan File For Virus using cURL

Scan File For Virus using cURL

SharpAPIs provide you with a convenient API to scan you files of any size for viruses and any possible malware. In this topic we are going to show you how to Scan File For Virus using cURL. We are going to use the following file as our input file:

https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx

First we start a conversion job by making a POST request to the following URL and include these conversion parameters into your request: inputFile and async

Request parameter descriptions (for the full and detailed description, please click here):

X-ApplicationID Your application ID (which you get from your Doc Conversion API Account)
X-SecretKey Your secret key  (which you get from your Doc Conversion API Account)
inputFile The file you would like to scan or a URL
async Defines if the request should be sync or async

Scan File For Virus using cURL

Scanning URL

https://api.virusscannerapi.com/virusscan

URL Virus Scanning Example
curl -H "Content-Type: multipart/form-data" -H "X-ApplicationID: Get your key from https://app.docconversionapi.com/#/applications" -H "X-SecretKey: Get your key from https://app.docconversionapi.com/#/applications" -F "async=false" -F "inputFile=https://www.docconversionapi.com/samples/example.docx" -X POST "https://api.virusscannerapi.com/virusscan"
Local File Virus Scanning Example
curl -H "Content-Type: multipart/form-data" -H "X-ApplicationID: Get your key from https://app.docconversionapi.com/#/applications" -H "X-SecretKey: Get your key from https://app.docconversionapi.com/#/applications" -F "async=false" -F "[email protected]" -X POST "https://api.virusscannerapi.com/virusscan"

After the scanning job has finished processing your file, you will get a response like the following:

{
    "id": 0,
    "userId": null,
    "fileName": "https://virusbotaccount.blob.core.windows.net/automatedtestfiles/demo.docx",
    "startedAt": "2020-03-25T12:16:55.0340019+00:00",
    "finishedAt": "2020-03-25T12:16:55.2484882+00:00",
    "status": "File is clean",
    "userIpAddress": "172.96.111.111"
}

 

If you have decided to make an async request instead of sync then your response will have the same structure but will not contain information like finishedAt etc.

To get your scanning result you will need to send a GET request to the following URL and use the previously returned ID of your scanning job.
https://api.virusscannerapi.com/virusscan/{{id}}

If you have any questions or need any further help, please contact us at [email protected].

Convert PDF to DOCX Using Ruby

Convert PDF to DOCX Using Ruby

In this topic we are going to show you how to Convert PDF to DOCX Using Ruby. We are going to use the following file as our input file:

https://www.docconversionapi.com/samples/example.pdf

First we start a conversion job by making a POST request to the following URL and include these conversion parameters into your request: inputFile, outputFormat, conversionParameters and async

Request parameter descriptions (for the full and detailed description, please click here):

X-ApplicationID Your application ID (which you get from your Doc Conversion API Account)
X-SecretKey Your secret key  (which you get from your Doc Conversion API Account)
outputFormat DOC
inputFile The file you would like to convert or a URL
conversionParameters A JSON String containing additional conversion options
async Defines if the request should be sync or async

Convert HTML to PDF Using Python

Conversion URL

https://api2.docconversionapi.com/jobs/create

URL conversion example (pdf to docx)
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

uri = URI.parse("https://api2.docconversionapi.com/jobs/create")

headers = { 
    'X-ApplicationID': 'Get your key from https://app.docconversionapi.com/#/applications',
    'X-SecretKey': 'Get your key from https://app.docconversionapi.com/#/applications'
}
form_data = {
    "inputFile" => "https://www.docconversionapi.com/samples/example.pdf",
    "outputFormat" => "docx",
    "conversionParameters" => "{}",
    "async" => "false"
}

# Create the HTTP objects
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
request = Net::HTTP::Post.new(uri.path, headers)
request.set_form form_data, 'multipart/form-data'

# Send the request
response = https.request(request)
puts response.body
 Local file conversion example (pdf to docx)
require 'net/http'
require 'net/https'
require 'uri'
require 'json'
require 'net/http/post/multipart'

uri = URI.parse("https://api2.docconversionapi.com/jobs/create")

File.open("example.docx") do |inputFile|

form_data = {
    "inputFile" => UploadIO.new(inputFile, "application/pdf", "example.pdf"),
    "outputFormat" => "docx",
    "conversionParameters" => "{}",
    "async" => "false"
}

# Create the HTTP objects
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
request = Net::HTTP::Post::Multipart.new(uri.path, form_data)
request.add_field('X-ApplicationID', 'Get your key from https://app.docconversionapi.com/#/applications')
request.add_field('X-SecretKey', 'Get your key from https://app.docconversionapi.com/#/applications')

# Send the request
response = https.request(request)
puts response.body
end

After the conversion job has finished processing your file, you will get a response like the following:

{
    "id": 1,
    "fileName": "example.pdf",
    "fileId": "fd4957df-8514-4e49-bfa4-123v8dta06r1",
    "userId": 2059,
    "startedAt": "2020-02-07T14:07:22.347669+00:00",
    "finishedAt": "2020-02-07T14:07:37.0907497+00:00",
    "outputFileName": "fd4957df-8514-4e49-bfa4-123v8dta06r1.docx",
    "outputFormat": "pdf",
    "conversionParametersApplied": "{}",
    "creditCost": 1,
    "status": "Success",
    "fileDownloadUrl": "https://api2.docconversionapi.com/files?userId=2059&fileId=fd4957df-8514",
    "statusCode": 200,
    "errorMessage": null
}

If you have decided to make an async request instead of sync then your response will have the same structure but will not contain information like fileDownloadUrl, fileId, outputFileName etc.

To get your conversion result you will need to send a GET request to the following URL and use the previously returned ID of your conversion job.
https://api2.docconversionapi.com/jobs/{{id}}

If you have any questions or need any further help, please contact us at [email protected].

Convert PNG to PDF Using Ruby

Convert PNG to PDF Using Ruby

In this topic we are going to show you how to Convert PNG to PDF Using Ruby. We are going to use the following file as our input file:

https://www.docconversionapi.com/samples/example.png

First we start a conversion job by making a POST request to the following URL and include these conversion parameters into your request: inputFile, outputFormat, conversionParameters and async

Request parameter descriptions (for the full and detailed description, please click here):

X-ApplicationID Your application ID (which you get from your Doc Conversion API Account)
X-SecretKey Your secret key  (which you get from your Doc Conversion API Account)
outputFormat DOC
inputFile The file you would like to convert or a URL
conversionParameters A JSON String containing additional conversion options
async Defines if the request should be sync or async

Convert HTML to PDF Using Python

Conversion URL

https://api2.docconversionapi.com/jobs/create

URL conversion example (png to pdf)
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

uri = URI.parse("https://api2.docconversionapi.com/jobs/create")

headers = { 
    'X-ApplicationID': 'Get your key from https://app.docconversionapi.com/#/applications',
    'X-SecretKey': 'Get your key from https://app.docconversionapi.com/#/applications'
}
form_data = {
    "inputFile" => "https://www.docconversionapi.com/samples/example.png",
    "outputFormat" => "pdf",
    "conversionParameters" => "{}",
    "async" => "false"
}

# Create the HTTP objects
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
request = Net::HTTP::Post.new(uri.path, headers)
request.set_form form_data, 'multipart/form-data'

# Send the request
response = https.request(request)
puts response.body
 Local file conversion example (png to pdf)
require 'net/http'
require 'net/https'
require 'uri'
require 'json'
require 'net/http/post/multipart'

uri = URI.parse("https://api2.docconversionapi.com/jobs/create")

File.open("example.docx") do |inputFile|

form_data = {
    "inputFile" => UploadIO.new(inputFile, "image/png", "example.png"),
    "outputFormat" => "pdf",
    "conversionParameters" => "{}",
    "async" => "false"
}

# Create the HTTP objects
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
request = Net::HTTP::Post::Multipart.new(uri.path, form_data)
request.add_field('X-ApplicationID', 'Get your key from https://app.docconversionapi.com/#/applications')
request.add_field('X-SecretKey', 'Get your key from https://app.docconversionapi.com/#/applications')

# Send the request
response = https.request(request)
puts response.body
end

After the conversion job has finished processing your file, you will get a response like the following:

{
    "id": 1,
    "fileName": "example.png",
    "fileId": "fd4957df-8514-4e49-bfa4-123v8dta06r1",
    "userId": 2059,
    "startedAt": "2020-02-07T14:07:22.347669+00:00",
    "finishedAt": "2020-02-07T14:07:37.0907497+00:00",
    "outputFileName": "fd4957df-8514-4e49-bfa4-123v8dta06r1.pdf",
    "outputFormat": "pdf",
    "conversionParametersApplied": "{}",
    "creditCost": 1,
    "status": "Success",
    "fileDownloadUrl": "https://api2.docconversionapi.com/files?userId=2059&fileId=fd4957df-8514",
    "statusCode": 200,
    "errorMessage": null
}

If you have decided to make an async request instead of sync then your response will have the same structure but will not contain information like fileDownloadUrl, fileId, outputFileName etc.

To get your conversion result you will need to send a GET request to the following URL and use the previously returned ID of your conversion job.
https://api2.docconversionapi.com/jobs/{{id}}

If you have any questions or need any further help, please contact us at [email protected].