talira

mime-types

Ruby library and registry of MIME content types and their file extensions

open sourceMITfree

mime-types is a Ruby library for information about MIME content types. It looks up a type's known filename extensions, or the likely types for a filename extension, and gives each type's details: its media and sub type, preferred extension, a friendly name, its encoding, and whether it's registered, obsolete or binary. Its definitions come from RFCs, W3C recommendations, the IANA Media Types registry and user contributions, and since version 3.0 the registry data ships separately in the mime-types-data gem. It conforms to RFCs 2045 and 2231.

Problems it solves

  • find the right Content-Type for a file from its extension in my Ruby app
  • look up which file extensions belong to a MIME type
  • check whether a MIME type is registered, obsolete or binary before I handle an upload

Features

  • Look up the MIME types for a filename extension, or the extensions for a MIME type
  • Details for each type: media and sub type, preferred extension, friendly name and encoding
  • Flags for registered, provisional, obsolete, binary and ASCII types
  • Definitions from RFCs, W3C recommendations and the IANA Media Types registry, kept in the mime-types-data gem