Apr 21, 2021
Thi example is the best so far.
Other ones even in official Wiki is out of date already.
Only minor issue is about dependencies.
Just add this to Gemfile
gem 'mimemagic', '0.3.9'
Reference
https://www.rubydoc.info/github/mimemagicrb/mimemagic#license