MIME File Type Idenfitier
MIME is media type often abbreviated from Multipurpose Internet Mail Extensions.
How we detect MIME Type from a file? Well, we read the file signatures, also known as 'magic bytes'.
More advance explanation
So, we can ready the file signatures, mostly from the header / first few bytes of file.
Then, we can match the bytes to coresponding unique magic bytes
For example, we have a file with following bytes (we cut few bytes for the sake of simplicity)
89 50 4E 47 0D 0A 1A 0A
BA BE FA CE AA BB CC DD
CA FE D0 D0 BE EE EE EF
89 50 4E 47 0D 0A 1A 0A match PNG signature, hence it will be treated as PNG file (this condition true on most linux systems)
- if you use linux systems you will notice that the linux will treat the file based on the file signatures, not extension