Determine file type in Ruby

后端 未结 13 1096
耶瑟儿~
耶瑟儿~ 2020-11-30 22:21

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

13条回答
  •  囚心锁ツ
    2020-11-30 22:55

    I recently found mimetype-fu.

    It seems to be the easiest reliable solution to get a file's MIME type.

    The only caveat is that on a Windows machine it only uses the file extension, whereas on *Nix based systems it works great.

提交回复
热议问题