Get MIME information of a file

I just want to check the content of the file. If I upload a .js file it is showing incorrect type ( application/ecmascript instead of application/javascript ).

What’s the most suitable way to do this in ruby?