Media type

From HandWiki
Short description: Identifier for file formats

A media type (formerly known as a MIME type)[1] is a two-part identifier for file formats and format contents transmitted on the Internet. Their purpose is somewhat similar to file extensions in that they identify the intended data format. The Internet Assigned Numbers Authority (IANA) is the official authority for the standardization and publication of these classifications. Media types were originally defined in Request for Comments RFC 2045 (MIME) Part One: Format of Internet Message Bodies (Nov 1996) in November 1996 as a part of the MIME (Multipurpose Internet Mail Extensions) specification, for denoting type of email message content and attachments;[2] hence the original name, MIME type. Media types are also used by other internet protocols such as HTTP[3] and document file formats such as HTML,[4] for similar purposes.

Naming

A media type consists of a type and a subtype, which is further structured into a tree. A media type can optionally define a suffix and parameters:

mime-type = type "/" [tree "."] subtype ["+" suffix]* [";" parameter];

As an example, an HTML file might be designated text/html; charset=UTF-8. In this example, text is the type, html is the subtype, and charset=UTF-8 is an optional parameter indicating the character encoding.

Types, subtypes, and parameter names are case-insensitive. Parameter values are usually case-sensitive, but may be interpreted in a case-insensitive fashion depending on the intended use.[2]

Types

The "type" part defines the broad use of the media type. As of November 1996, the registered types were: application, audio, image, message, multipart, text and video.[2] By December 2020, the registered types included the foregoing, plus font, example, and model.[1]

An unofficial top-level type in common use is chemical.[5][6][7]

Subtypes

A subtype typically consists of a media format, but it may or must also contain other content, such as a tree prefix, producer, product or suffix, according to the different rules in registration trees.

All media types should be registered using the IANA registration procedures. For the efficiency and flexibility of the media type registration process, different structures of subtypes can be registered in registration trees that are distinguished by the use of tree prefixes. Currently the following trees are created: standard (no prefix), vendor (vnd. prefix), personal or vanity (prs. prefix), unregistered (x. prefix). These registration trees were first defined in November 1996 (obsoleted RFC 2048 - currently RFC 6838). New registration trees may be created by IETF Standards Action for external registration and management by well-known permanent organizations (e.g. scientific societies).

Standards tree

The standards tree does not use any tree prefix. Examples are text/javascript, image/png.[8]

Registrations in the standards tree must be either associated with IETF specifications approved directly by the IESG, or registered by an IANA recognized standards-related organization.

Vendor tree

The vendor tree includes media types associated with publicly available products. It uses the vnd. tree prefix. Examples are: application/vnd.ms-excel, application/vnd.oasis.opendocument.text.

The terms "vendor" and "producer" are considered equivalent in the context. Industry consortia as well as non-commercial entities can register media types in the vendor tree. A registration in the vendor tree may be created by anyone who needs to interchange files associated with some software product or set of products. However, the registration belongs to the vendor or organization producing the software that employs the type being registered, and that vendor or organization can at any time elect to assert ownership of a registration done by a third party.

Personal or vanity tree

The personal or vanity tree includes media types associated with non publicly available products or experimental media types. It uses the prs. tree prefix. Examples are audio/prs.sid, image/prs.btif.

Unregistered tree

The unregistered tree includes media types intended exclusively for use in private environments and only with the active agreement of the parties exchanging them. It uses the x. tree prefix. Examples are application/x.foo, video/x.bar. Media types in this tree cannot be registered.

This type was originally defined in RFC 1590 (published in September 1993) using the x- or X- prefix. RFC 2048 (published in November 1996) introduced the x. prefix, but discouraged use of the unregistered tree, as new personal and vendor trees with relaxed registration requirements are now available. The current RFC 6838 (published in January 2013) maintains the same recommendation, but subtypes prefixed with x- or X- are no longer considered to be members of this tree.

Media types that have been widely deployed (with a subtype prefixed with x- or X-) without being registered, should be, if possible, re-registered with a proper prefixed subtype. If this is not possible, the media type can, after an approval by both the media types reviewer and the IESG, be registered in the standards tree with its unprefixed subtype. application/x-www-form-urlencoded is an example of a widely deployed type that ended up registered with the x- prefix.[9]

Suffix

Suffix is an augmentation to the media type definition to additionally specify the underlying structure of that media type, allowing for generic processing based on that structure and independent of the exact type's particular semantics. Media types that make use of a named structured syntax should use the appropriate IANA registered "+"suffix for that structured syntax when they are registered. Unregistered suffixes should not be used (since January 2013). Structured syntax suffix registration procedures are defined in RFC 6838.[8]

The +xml suffix has been defined since January 2001 (RFC 3023[10]), and was formally included in the initial contents of the Structured Syntax Suffix Registry along with +json, +ber, +der, +fastinfoset, +wbxml, and +zip in January 2013 (RFC 6839). Subsequent additions include +gzip, +cbor, +json-seq, and +cbor-seq.[11]

Common examples

From the IANA registry:[1]


  • application/json
  • application/ld+json (JSON-LD)
  • application/msword (.doc)
  • application/pdf
  • application/sql
  • application/vnd.api+json
  • application/vnd.microsoft.portable-executable (.efi)
  • application/vnd.ms-excel (.xls)
  • application/vnd.ms-powerpoint (.ppt)
  • application/vnd.oasis.opendocument.text (.odt)
  • application/vnd.openxmlformats-officedocument.presentationml.presentation (.pptx)
  • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (.xlsx)
  • application/vnd.openxmlformats-officedocument.wordprocessingml.document (.docx)
  • application/x-www-form-urlencoded
  • application/xml
  • application/zip
  • application/zstd (.zst)
  • audio/mpeg
  • audio/ogg
  • image/avif
  • image/jpeg (.jpg, .jpeg, .jfif, .pjpeg, .pjp) [12]
  • image/png
  • image/svg+xml (.svg)
  • image/tiff (.tif)
  • model/obj (.obj)
  • multipart/form-data
  • text/plain
  • text/css
  • text/csv
  • text/html
  • text/javascript(.js)
  • text/xml


Mailcap

Mailcap (derived from the phrase "mail capability") is a type of meta file used to configure how MIME-aware applications such as mail clients and web browsers render files of different MIME-types. The mailcap format is defined by RFC 1524 "A User Agent Configuration Mechanism for Multimedia Mail Format Information" but is not defined as an Internet standard. It is supported by most Unix systems.

Lines can be comments starting with the # character, or a mime-type followed by how to handle that mime type.

mime.types

An associated file is the mime.types file, which associates filename extensions with a MIME type. If the MIME type is properly set, this is unnecessary, but MIME types may be incorrectly set, or set to a generic type such as application/octet-stream, and mime.types allows one to fall back on the extension in these cases. Similarly, since many file systems do not store MIME type information, but instead rely on the filename extension, a mime.types file is frequently used by web servers to determine MIME type.

When viewing a file, these two work together as follows: mime.types associates an extension with a MIME type, while mailcap associates a MIME type with a program.

In UNIX-type systems, the mime.types file is usually located at /etc/mime.types and/or $HOME/.mime.types and the format is simply that each line is a space-delimited list of a MIME type, followed by zero or more extensions. For example, the HTML type can be associated with the extensions .htm and .html by the following line:

text/html     htm   html

Netscape use

The mime.types file dates to Netscape, where it used a different format;[13] it used key–value pairs and a comma-separated list of extensions, together with a standard header consisting of a specific comment that identifies the file as a mime.types file, as follows:

#--Netscape Communications Corporation MIME Information
# Do not delete the above line. It is used to identify the file type.

type=text/html exts=htm,html

See also

References

  1. 1.0 1.1 1.2 "Media Types". IANA. 4 June 2018. https://www.iana.org/assignments/media-types/media-types.xhtml. "[RFC2046] specifies that Media Types (formerly known as MIME types) and Media Subtypes will be assigned and listed by the IANA." 
  2. 2.0 2.1 2.2 Freed, N.; Borenstein, N. (November 1996). "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies". Internet Engineering Task Force. https://tools.ietf.org/html/rfc2045. 
  3. Nielsen, Henrik; Fielding, Roy T.; Berners-Lee, Tim (May 1996). "Hypertext Transfer Protocol -- HTTP/1.0". https://tools.ietf.org/html/rfc1945#section-3.6. 
  4. "HTML 4.01 Specification". 24 Dec 1999. https://www.w3.org/TR/html401/types.html#type-content-type. 
  5. Daniel Leidert, Egon Willighagen (2007). "The chemical-mime-data project". http://chemical-mime.sourceforge.net/. 
  6. "Chemical MIME Home page". 22 December 1998. https://www.ch.ic.ac.uk/chemime/. 
  7. S. Rzepa, Henry; Murray-Rust, Peter; J. Whitaker, Benjamin (14 August 1998). "The Application of Chemical Multipurpose Internet Mail Extensions (Chemical MIME) Internet Standards to Electronic Mail and World Wide Web Information Exchange". Journal of Chemical Information and Modeling (American Chemical Society) 38 (6): 976–982. doi:10.1021/ci9803233. 
  8. 8.0 8.1 Freed, N. (January 2013). "Media Type Specifications and Registration Procedures". IETF Request for Comments (RFC) Pages - Test (Internet Engineering Task Force (IETF)) RFC6838. ISSN 2070-1721. https://tools.ietf.org/html/rfc6838. Retrieved 15 July 2015. 
  9. "application/x-www-form-urlencoded (registered 2014-05-14, updated 2014-05-14, updated 2020-07-14)". https://www.iana.org/assignments/media-types/application/x-www-form-urlencoded. 
  10. Kohn, Dan (January 2001) (in en). XML Media Types. https://tools.ietf.org/html/rfc3023.html. Retrieved 2021-03-05. 
  11. "Structured Syntax Suffix Registry" (XML). IANA. 2012-07-20. https://www.iana.org/assignments/media-type-structured-suffix/media-type-structured-suffix.xml. 
  12. "MIME types (IANA media types) - HTTP | MDN". https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#jpeg. 
  13. WEBMASTERS: mime types , John McAnally, Thu, 22 Jan 1998 15:29:29 -0600 (CST)

External links