Determine file type in Ruby

后端 未结 13 1090
耶瑟儿~
耶瑟儿~ 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 23:00

    You could give a go with MIME::Types for Ruby.

    This library allows for the identification of a file’s likely MIME content type. The identification of MIME content type is based on a file’s filename extensions.

提交回复
热议问题