python-magic icon indicating copy to clipboard operation
python-magic copied to clipboard

Ability to detect whether detect mimetype corresponds to the file extension

Open C0rn3j opened this issue 1 year ago • 1 comments

As per https://github.com/ahupp/python-magic/issues/228#issuecomment-741967910, libmagic should be able to do this, but I do not see a way to get this library to give me the list of possible file extensions for a given file type.

Would be nice to have a verify_file_extension() function or something akin to it, but I can write that myself, it's just that I can't get the list at all.

mimetypes library does have a function for this.

C0rn3j avatar Dec 28 '24 18:12 C0rn3j