Currently only file extensions are taken into account which relies on an often unreliable piece of metadata which is the file name.
The more robust way would be to also check its signature using a file magic library and if it fails fall back to file extension.