ahupp / python-magic

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

application/octet-stream with text files on windows #275

Open prchristie opened 2 years ago

prchristie commented 2 years ago

On Windows 10 a plain text buffer is classified as application/octet-stream which is indicative of a binary file (I think). Ubuntu Linux is correctly identifying as "text/plain".

Python3.9, python-magic-bin as the driver for magiclib

How to reproduce

content = "Bunch of fake content" * 8192

magic = Magic(mime=True)
mimetype = magic.from_buffer(content[0:8192]) # Index to replicate my environment
zwnk commented 1 year ago

I have the exact same issue. With Ubuntu it gives me the correct file type, Windows its always application/octet-stream.