elebow / mimemagic

Mime type detection in ruby via file extension or file content

Home Page:https://github.com/minad/mimemagic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MimeMagic is a library to detect the mime type of a file by extension or by content. It uses the mime database provided by freedesktop.org (see http://freedesktop.org/wiki/Software/shared-mime-info/).

Gem Version

Usage

require 'mimemagic'
MimeMagic.by_extension('html').text?
MimeMagic.by_extension('.html').child_of? 'text/plain'
MimeMagic.by_path('filename.txt')
MimeMagic.by_magic(File.open('test.html'))
# etc...

You can add your own magic with MimeMagic.add.

API

http://www.rubydoc.info/github/minad/mimemagic

Tests

bundle install

rake test

Authors

Daniel Mendler

LICENSE

GPL-2.0

About

Mime type detection in ruby via file extension or file content

https://github.com/minad/mimemagic

License:GNU General Public License v2.0


Languages

Language:Ruby 100.0%