ahupp / python-magic

A python wrapper for libmagic
Other
2.6k stars 281 forks source link

Added support for magic_descriptor routine #227

Closed psrok1 closed 3 years ago

psrok1 commented 3 years ago

In our case we need to operate on already opened and unnamed file (e.g. TemporaryFile created as a werkzeug's FileStorage).

libmagic implements from_descriptor method to use file descriptor as a source, but it's not supported by python-magic wrapper. I've added that functionality in this PR. I hope you like it.

Thanks for great Python binding, it's really useful! ❤️

ahupp commented 3 years ago

Thanks, this looks good! It will probably fail on older versions of libmagic that don't have this function, but I'll fix that up in a followup. The test suite will find those.