How does one reliably determine a file\'s type? File extension analysis is not acceptable. There must be a rubyesque tool similar to the UNIX file(1) comman
This was added as a comment on this answer but should really be its own answer:
path = # path to your file IO.popen( ["file", "--brief", "--mime-type", path], in: :close, err: :close ) { |io| io.read.chomp }
I can confirm that it worked for me.