Skip to content

Instantly share code, notes, and snippets.

@cmthakur
Created May 31, 2012 04:25
Show Gist options
  • Save cmthakur/2841029 to your computer and use it in GitHub Desktop.
Save cmthakur/2841029 to your computer and use it in GitHub Desktop.
Extract the file type in ruby.
You can simply find the file type of a file where file.content_type doesnot works
options[:form] = "./lib/cf/cli/templates/sample-line/form.html"
file_type = IO.popen(["file", "--brief", "--mime-type", options[:form]], in: :close, err: :close).read.chomp
The return type is simply "text/html"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment