Wednesday, May 30, 2012

Extract 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"

No comments:

Post a Comment