private static function guessFromFinfo(string $filename): string
    {
        $result = 'application/octet-stream';

        if (!function_exists('finfo_file')) {
            return $result;
        }

        $handle = finfo_open(FILEINFO_MIME);
        if ($handle === false) {
            return $result;
        }

        $info = finfo_file($handle, $filename);
        finfo_close($handle);

        return $info !== false ? $info : $result;
    }