Skip to content

Instantly share code, notes, and snippets.

@linjunpop
Created May 8, 2013 02:14
Show Gist options
  • Select an option

  • Save linjunpop/5537725 to your computer and use it in GitHub Desktop.

Select an option

Save linjunpop/5537725 to your computer and use it in GitHub Desktop.
Get file content type from filename.
filename = 'foobar.zer.png'
def content_type
extname = File.extname(filename)[1..-1]
Mime::Type.lookup_by_extension(extname)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment