As I understand @murphy he wants to check the magic number of the file, instead of relying on the file extension (which can be as wrong as anything a browser thinks to set as MIME-type).
Also, because of this thread, I hacked a wrapper which is available as file_info from hex.pm. It is very basic right now, but I do plan to make it better.
Something interesting would be to extract the header of the file and pattern-match it against a pre-defined map of type <-> headers.
If someone wants to play with bitstrings…
As you can see in issue #4, I do plan in the long term, that I want to remove the necessy of find beeing available and to the tests directly on Elixir side, but I really think it will tike quite a while, since there are many MIME-types with many magic numbers.
At first I’d need some reliable source of such magic numbers and their mapping to MIME-types.
I will take a closer look later this month if this can help.
I have thought about this, but I don’t think that a sequential pattern match is fast enough. Since these magic numbers are of different length and you only now the length after you had a successfull match, I think some kind of Trie
Because there is some invalid character in the MIME-Type. Please check the result of calling file --mime-type on the file in question. Also please feel free to open a bugt report at https://gitlab.com/NobbZ/file_info/issues.
Is that the full output? There has to be something else confusing the system… And is that the same machine than the one you have the problem with or is it another machine you try to upload from?