Extras
Media Types
Many programs send different types of file across the Internet:
- Browsers display HTML pages that also include style sheets, scripts, images, audio and video
- Messaging apps are commonly used to send images, audio and video
- Email programs can receive many kinds of attachments
Media types tell these programs the format of files and their contents so that they can be processed and/or displayed correctly.
Media types were originally defined in a specification called Multipurpose Internet Mail Extensions and were called MIME types.
The name was changed to Media Types because they were not only used in emails, but also in many other internet protocols such as HTTP, and other document formats such as HTML. They are sometimes called content types.
They are controlled by the Internet Assigned Numbers Authority (IANA), who also control IP addresses, domain names, and other internet protocols.
A Media Type is made up of two parts separated by a forward slash:
- The type is a category of file format, such as audio, image, text, or video
- The subtype identifies the format of the file; for example, an image could be a GIF, JPEG, PNG, or WebP
There are two classes of type: discrete and multipart. Discrete types represent a single file or medium (such as a single piece of text, music or video), whereas multipart types represent a document composed of multiple parts.
Full list of media types: https://www.iana.org/assignments/media-types/
Type | / | Subtype |
---|---|---|
image | / | jpg |
text | / | html |
audio | / | mp3 |
video | / | quicktime |
Discrete Types
Discrete Media Types represent an individual file or medium. Below you can see the discrete types and some examples of their subtypes.
Image Media Type
The image
media type is used for image or graphical data including bitmap and vector images. It is also used for animated formats of still images such as GIF.
Type | Description |
---|---|
image/gif | GIF image |
image/jpeg | JPEG image |
image/png | PNG image |
image/svg+xml | SVG image |
image/webp | WebP image |
Audio Media Type
The audio
type is for audio files and music data.
Type | Description |
---|---|
audio/mpeg | includes MPEG-based formats such as MP3 |
audio/mp4 | includes formats such as M4A (non-protected audio), M4B (audiobooks / podcasts) and M4P (DRM protected audio) |
audio/aac | Advanced Audio Coding format |
audio/rtp-midi | for transporting midi in Real-Time Protocol (RTP) packets |
Video Media Type
The video
type is for video files and data.
Type | Description |
---|---|
video/h264 | h264 video |
video/mp4 | mp4 video |
video/quicktime | Quicktime video |
video/raw | Raw video |
Text Media Type
The text
type is for text-only data that is designed either for humans to read or for computers to process.
Type | Description |
---|---|
text/plain | Plain text |
text/html | HTML documents |
text/css | CSS style sheets |
text/php | PHP code |
text/csv | Comma-separated values |
Font Media Type
The font
type is used to specify font or typeface data.
Type | Description |
---|---|
font/ttf | True Type font files |
font/oft | Open-Type font files |
font/woff | Web Open Font Format |
Application Media Type
The application
type is for files that are used by many types of applications, and that do not fall into one of the other types.
Type | Description |
---|---|
application/javascript | JavaScript files |
application/pdf | PDF files |
application/sql | SQL files |
application/zip | ZIP files |
application/octet-stream | Generic binary data, or unknown files |
Model Media Type
The model
type is for model data or 3D objects and scenes.
Type | Description |
---|---|
model/vrml | Virtual Reality Modelling Language |
model/vnd.collada+xml | Collada file format for 3D applications, written in XML |
Example Media Type
The example
type is used as a placeholder for examples that show how to use media types. They should only be used in sample code and documentation.
Type | Description |
---|---|
example/format | Here, example is being used to describe a type |
audio/example | Here, example is being used to describe a subtype |
Multipart Types
Multipart types are used for documents that are broken into pieces. This might be for one of two reasons:
- The individual pieces of the document have different Media Types
- A large field needs to be broken into parts for transmission, then re-assembled when it has been received
Below, you can see the two multipart media types.
The message
type is for messages that either include other messages (for example an email that contains a forwarded email), or for very large messages that are sent in chunks.
Type | Description |
---|---|
message/rfc822 | For forwarded messages and replied-to messages |
message/partial | For parts of messages that are split up into chunks |
The multipart
type is used for data that will contain mutliple components that can have their own media type.
Type | Description |
---|---|
multipart/form-data | Used to send form data that may also contain files |
Extra Information in Subtypes
Subtypes can use prefixes, suffixes and optional parameters to provide extra information.
Prefixes
The following three prefixes can be used at the start of a subtype. These prefixes are sometimes referred to as registration trees as they have more information about how the media types are registered with the IANA.
vnd.
indicates that they are for use with software created by a specific vendorprs.
indicates that it is a personal or experimental formatx-
indicates that they are unregistered with IANA
Type | Description |
---|---|
application/vnd.apple.keynote | Apple Keynote |
application/vnd.ms-powerpoint | Microsoft Powerpoint |
image/vnd.adobe.photoshop | Adobe Photoshop |
application/x-x509-ca-cert | X.509 security certificates |
Suffixes
When a file format is derived from either a standard or another file format, this can be indicated using a suffix.
To do this, the subtype is followed by a +
symbol, then the name of the standard or format it is based on.
The examples show that the formats are written using Extensible Markup Language (XML).
Type | Description |
---|---|
image/svg+xml | Indicates that SVG is written in XML |
application/mathml+xml | Indicates that MathML is written in XML |
application/atom+xml | Indicates that the Atom feed is written in XML |
Parameters
Parameters are specified by adding a semi-colon after the Media Type, followed by the name of the parameter, then an equals symbol, and then the value for the parameter.
Type | Description |
---|---|
text/html;charset=UTF-8 | Indicates that the HTML file uses UTF-8 character encoding |
video/mp4;codecs="ac-3" | Indicates that the MP4 video file uses AC-3 audio encoding |
For a full list of media types see: https://www.iana.org/assignments/media-types/
NOTE: Browsers use the media type of files, not their file extension, to determine how to process them. Therefore, web servers must be configured to send the correct media type in the response's Content-Type
header, otherwise the file may not be rendered or handled correctly.