6.2 Retrieving Sanitized Files

Request

Value

Method

GET

URL

https://api.metadefender.com/v3/file/:fileId/sanitizedLink

Summary

Retrieve the S3 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

:fileId

The fileId of the file that underwent data sanitization

Header Parameters

 

Description

Allowed Values

Required

Authorization

give 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 in-progress file handling:

{
"success": true,
"data": {
"sanitizedFilePath": "https://s3-us-west-2.amazonaws.com/g.files.metadefender.com/dt%3D170329/HkzNi94Y2l.sanitized?AWSAccessKeyId=AKIAJATVWRQL5FM5ZFNQ&Expires=1491381246&Signature=wMk0E8b3wH1%2F6YNrwIWZohhtRjk%3D&response-content-disposition=attachment%3B%20filename%3Dtest_jpg.jpg"
}
}

Descriptions of responses:

success

evaluation of request

data

response data holder

data.message

signed S3 URL for the sanitized file

Example of successful scan request:

{
"file_id": "cDE2MTIxMkIxUXhqdlZuM21n",
"data_id": "cDE2MTIxMkIxUXhqdlZuM21nU0pOeG92NGgyUWc",
"sanitized": {
"file_path": "https://s3-us-west-2.amazonaws.com/p.files.metadefender.com/dt%3D161212/B1QxjvVn3mg.sanitized?AWSAccessKeyId=KEYID&Expires=1481588777&Signature=SIGNATURE%3D&response-content-disposition=attachment%3B%20filename%3DUnknown%20Filename",
"data_id": "cDE2MTIxMkIxUXhqdlZuM21nU3lQdVZoM1hl",
"result": "Allowed"
},
"process_info": {
"profile_obj_id": "57e1ff5a64d3191340c72c7c",
"file_type_skipped_scan": false,
"blocked_reason": "",
"result": "Allowed",
"profile": "Sanitization archive disabled",
"user_agent": "mcl-metadefender-rest-sanitize-disabled-unarchive",
"progress_percentage": 100
},
"scan_results": {
"scan_details": {
"DrWebGateway": {
"threat_found": "",
"scan_result_i": 0,
"def_time": "2016-12-12T00:00:00Z",
"scan_time": 125
},
"Emsisoft": {
"threat_found": "",
"scan_result_i": 0,
"def_time": "2016-12-12T00:00:00Z",
"scan_time": 516
},
"K7": {
"threat_found": "",
"scan_result_i": 0,
"def_time": "2016-12-12T00:00:00Z",
"scan_time": 31
},
"AegisLab": {
"threat_found": "",
"scan_result_i": 0,
"def_time": "2016-12-12T00:00:00Z",
"scan_time": 1531
},
"Agnitum": {
"threat_found": "",
"scan_result_i": 0,
"def_time": "2016-12-12T00:00:00Z",
"scan_time": 1219
},
...
},
"rescan_available": false,
"data_id": "cDE2MTIxMkIxUXhqdlZuM21nU0pOeG92NGgyUWc",
"scan_all_result_i": 0,
"start_time": "2016-12-12T23:35:53.565Z",
"total_time": 6672,
"total_avs": 41,
"total_detected_avs": 0,
"progress_percentage": 100,
"in_queue": 0,
"scan_all_result_a": "Clean"
},
"file_info": {
"file_size": 117956,
"upload_timestamp": "2016-12-12T23:35:53.565Z",
"md5": "F7F398105BC380EC35095C31DE52C0EA",
"sha1": "E52988C8A1BCCAD45ECC17AF989732A5A4C08EAE",
"sha256": "CFB047CEEECA5D1F0B03D08E1E62C9FF546A261B3E3662F6E6BBD0854EFA91F3",
"file_type_category": "P",
"file_type_description": "Adobe Portable Document Format",
"file_type_extension": "pdf/ai",
"display_name": "Unknown Filename"
},
"top_threat": -1
}

Descriptions of responses:

sanitized.file_path

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

sanitized.data_id

Data ID used for retrieving scan results of the sanitized file

sanitized.result

Result of the data sanitization operation. Allowed stands for successful sanitization. If an error occurs during sanitization, it will be recorded here.

process_info.profile_obj_id

Internal ID of workflow profile

process_info.file_type_skipped_scan

Indicates if the input file's detected type was configured to skip scanning

process_info.blocked_reason

Reason for blocked data sanitization

process_info.result

Result of the data sanitization process

process_info.profile

Profile used for data sanitization

process_info.user_agent

User agent associated with the workflow

process_info.progress_percentage

Process progress percentage. Once this is 100%, the process is finished and the data sanitization result is available.

Errors

Please refer to Errors for more information.

Sample code (Node.js)

var http = require("https");
 
var options = {
"method": "GET",
"hostname": "api.metadefender.com",
"port": null,
"path": "/v3/file/ZzE3MDMyOUhrek5pOTRZMmw/sanitizedLink",
"headers": {
"authorization": "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/v3/file/ZzE3MDMyOUhrek5pOTRZMmw/sanitizedLink \
-H 'Authorization: apikey ${APIKEY}'