magic

mautrix.util.magic.mimetype(data)

Uses magic to determine the mimetype of a file on disk or in memory.

Supports both libmagic’s Python bindings and the python-magic package.

Parameters

data (bytes | bytearray | str) – The file data, either as in-memory bytes or a path to the file as a string.

Returns

The mime type as a string.

Return type

str