Created
June 19, 2012 03:36
-
-
Save barlino/2952157 to your computer and use it in GitHub Desktop.
Using the magic gem to identify file mime type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#installation | |
gem install magic | |
#example | |
require "magic" | |
Magic.guess_file_mime("CKMetrics.pdf") | |
#=> "application/pdf; charset=binary" | |
Magic.guess_file_mime_type("translate_tts.mp3") | |
#=> "audio/mpeg" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment