gem 'file_type_detector'
And then execute:
$ bundle
Or install it yourself as:
$ gem install file_type_detector
Usage:
file = File.open('/path/to/file', 'r')
FileTypeDetector::Extension.extension(file)
# => '.jpg'
path = '/path/to/file'
FileTypeDetector::Extension.extension(path)
# => '.jpg'
string = File.read('/path/to/file')
FileTypeDetectorTest::Extension.extension(string)
# => '.jpg'
There is plenty to do, this gem currently only supports 'jpg' and 'png'
The gem is available as open source under the terms of the People's License
Everyone interacting in the FileTypeDetector project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.