7.4 Download link
Request |
Value |
Method |
GET |
URL |
https://api.metadefender.com/v4/file/:hash/download |
Summary
Retrieve the download link for a specific file. Any of the md5, sha1 and sha256 hashes can be used for downloading the file. This endpoint must be called for each file.
The returned URL is an s3 signed URL, which is the actual download link of the file. The s3 link will expire after a certain amount of time.
Metadefender cloud does not store the files in archives separate. So it might be the case that a file downloaded has a different hash than specified in the URL. In this case, the hash can be found inside the archive.
This endpoint is only available to OPSWAT partners participating in the malware exchange program. If you are an antivirus vendor, or have a malware feed and want to participate in the program, please contact us at malware-sharing@opswat.com.
Request
URL parameters
|
Description |
Required |
:hash |
Md5, sha1 or sha256 of the file to download |
YES |
Header Parameters
|
Description |
Allowed Values |
Required |
apikey |
Gives rights to use the endpoint (API Authentication Mechanisms) |
apikey |
YES |
Response
HTTP Status Codes
Please refer to Status Codes for more information.
Body
Example of a successful request:
{
"file_path"
:
"https://s3.us-west-2.amazonaws.com/e.files.metadefender.com/dt%3D170822/HyRfFN_xq_Z?AWSAccessKeyId=AKIAIQ4OFCFFFT4QMUYA&Expires=1553868684&Signature=yF0Hs72Sp%2FLef8KQrV2eLqTed7A%3D&response-content-disposition=attachment%3B%20filename%3DCleanupConsole.exe"
}
Example of a failed request:
{
"error"
: {
"code"
:
401007
,
"messages"
: [
"You are not authorized"
]
}
}
Descriptions of responses:
file_path |
S3 signed URL from where to download the file. |
Files inside archives
If a file is inside an archive, the following response will be returned:
{
"file_path"
:
null
,
"file_inside_archive"
:
true
,
"archive_sha256"
:
"0773515D27BCEECC718A94BE2BC0C361C3A78278BE7B31B20E5E7C2AD2725D24"
}
The file itself cannot be downloaded, but the archive containing this file can be downloaded. In these cases, perform another request to download the "archive_sha256".
Sample code (Node.js)
var http = require(
"https"
);
var options = {
"method"
:
"GET"
,
"hostname"
: [
"api"
,
"metadefender"
,
"com"
],
"path"
: [
"v4"
,
"file"
,
"6A5C19D9FFE8804586E8F4C0DFCC66DE"
,
"download"
],
"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/6A5C19D9FFE8804586E8F4C0DFCC66DE/download \
-H
"apikey: ${APIKEY}"