kumo.file_type.from_bytes
Since: Version 2025.12.02-67ee9e96
The functionality described in this section requires version 2025.12.02-67ee9e96 of KumoMTA, or a more recent version.
Attempts to determine the file type from the provided string, which may also be binary bytes.
This function will always succeed in returning a guess, which may or may not be accurate.
The return value is a FileTypeResult
local kumo = require 'kumo'
local utils = require 'policy-extras.policy_utils'
local ft = kumo.file_type.from_bytes '\xCA\xFE\xBA\xBE'
utils.assert_eq(ft, {
name = 'Java class file',
extensions = { 'class' },
media_types = {
'application/java',
'application/java-byte-code',
'application/java-vm',
'application/x-httpd-java',
'application/x-java',
'application/x-java-class',
'application/x-java-vm',
},
})