h2non/filetype.py

Add support to txt file

ghrimx opened this issue · 2 comments

Great package!
would it be possible to add support to txt file?

avibn commented

Hey, I was also looking into this today, and it seems plain text files don't typically have magic numbers. A way might be to check for a byte order mark, which could provide a close "guess".

h2non commented

Nope. Only binary files are supported in this library.
TXT cannot be reliably detected, however, you can presume it by checking the file extension and reading the first bytes to the file content is readable text.