Get Extension by Mimetype in Rails mdorfin 2023-02-09 34 words One minute Sometimes we need to get an extension by content mime type. There are many ways to manage this but in Rails (or rack-based app) you can use this trick: 1 Rack::Mime::MIME_TYPES.invert['image/jpeg'] # => '.jpg'