6.2 Retrieving Sanitized Files

Request

Value

Method

GET

URL

https://api.metadefender.com/v4/file/converted/:data_id

Summary

Retrieve the download link for sanitized files.

Retrieving sanitized files

On MetaDefender Cloud, scanning and data sanitization are performed asynchronously, and each scan and data sanitization request is tracked by a data_id. Initiating a file scan and retrieving the scan results and sanitized files need to be done with two separate API calls. This request needs to be made multiple times until the scan is complete. Scan completion can be traced using the property scan_results.progress_percentage value from the response. Data sanitization completion must be traced by using the property process_info.progress_percentage. The data sanitization URL expires after 50 minutes.

Request

URL Parameters

 

Description

:data_id

The fileId of the file that underwent data sanitization

Header Parameters

 

Description

Allowed Values

Required

apikey

gives rights to use the endpoint (token authentication) (API Authentication Mechanisms)

apikey must match the one used by the uploader

apikey

YES

Response

HTTP Status Codes

Please refer to Status Codes for more information.

Body

Example of a successful request:

{
"sanitizedFilePath": "https://s3.us-west-2.amazonaws.com/p.files.metadefender.com/dt%3D190122/rkss9asNm4.sanitized?AWSAccessKeyId=AKIAIQ4OFCFFFT4QMUYA&Expires=1553866358&Signature=F2jhbChGRFL1vyu%2B9S53YEIMCpw%3D&response-content-disposition=attachment%3B%20filename%3Dtest_pdf.pdf"
}

Example of a failed request:

{
"error": {
"code": 403001,
"messages": [
"Requested resource doesn't match your API key"
]
}
}

Descriptions of responses:

sanitizedFilePath

Location of the sanitized file, which is accessible only through this unique link

Errors

Please refer to Errors for more information.

Sample code (Node.js)

var http = require("https");
 
var options = {
"method": "GET",
"hostname": [
"api",
"metadefender",
"com"
],
"path": [
"v4",
"file",
"converted",
"bzE5MDEyMnJrc3M5YXNObTQ"
],
"headers": {
"apikey": process.env.APIKEY
}
};
 
var req = http.request(options, function (res) {
var chunks = [];
 
res.on("data", function (chunk) {
chunks.push(chunk);
});
 
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
 
req.end();

Sample code (cURL)

curl -X GET \
https://api.metadefender.com/v4/file/converted/bzE5MDEyMnJrc3M5YXNObTQ \
-H "apikey: ${APIKEY}"