public static function getTypeFromFile(string $path): string
    {
        if (!is_file($path) || !is_readable($path)) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'path'; ".
                "expecting an absolute path to a readable file"
            );
        }

        $finfo = new \finfo(FILEINFO_MIME_TYPE);
        $type = @$finfo->file($path);
        return ($type === false) ? "application/octet-stream" : $type;
    }