Introduction to MIME Types
A Multipurpose Internet Mail Extension [MIME] type identifies the format of a file. Applications such as Internet browsers and email applications use the MIME type of a file to decide which actions to perform on it. For example, an email application can use the MIME type to detect the format of an attachment and choose an appropriate viewer for the file, such as opening a text document with gedit.
As another example, the Nautilus file manager needs to know the MIME type of a file to perform the following tasks:
- Open the file in an appropriate application.
- Display a string that describes the type of file.
- Display an appropriate icon to represent the file.
- Display a list of other applications that can open the file.
MIME types were originally proposed as a standard for identifying the message body of an e-mail message. Now, many systems use MIME types to identify the format of arbitrary files on the file system. MIME types are composed of a top-level media type followed by a subtype identifier, separated by a forward slash character, “/”. One example of a MIME type is image/jpeg. The media type in this example is “image” and the subtype identifier is “jpeg”. The top-level media type is meant to be a general categorization about the content of the file, while the subtype identifer is meant to specifically identify the format of the file.
There are eight media types currently blessed by the IANA [Internet Assigned Naming Authority]. These eight media types are application、audio、image、message、model、multipart、text、video. Many subtypes exist for each media type; for more information, see MIME Media Types at the IANA web site.
Implementation of MIME types in GNOME follows the XDG shared mime info specification. This specification provides the following advantages:
- Standard locations for all MIME related files.
- A standard way for applications to register information about a new MIME type.
- A standard way to retrieve the MIME type for a file.
- A standard way to retrieve information about a MIME type.
The rest of the chapter describes the files and directories that make up the MIME database, details about source XML files, how to create or modify MIME types, how to register applications as handlers for certain MIME types and finally, how to add an application to the GNOME desktop.