Resource - Media Type (Mime)
Type
The term Internet media type refers to the type of a resource (in short, it tells the structure)
Syntax
A media type has the following syntax:
type/subtype
where type is one of the five discrete top-level media types:
- text for textual information where the subtype:
- plain designs plain text
- enriched designs a revision of the richtext subtext (defined in the RFC 1896)
- image for image data where the subtypes define the formats (Example: jpeg, gif)
- audio for audio data. “basic” behind the default subtype.
- video for video data. The default and initial subtype is mpeg
- application - for other kind of data that are readable by an application (by default binary data with the subtype octet-stream where the structure is not standardized )
The specific syntax rule is: A string is a valid MIME type with no parameters if it matches the media-type rule defined in section 3.1.1.1 “Media Types” of RFC 7231, but does not contain any ; U+003B characters. In other words, if it consists only of a type and subtype, with no MIME Type parameters.
Relation with Email
It is also known as MIME (Multipurpose Internet Mail Extensions) because the media type definition started with the email but ultimately, the media type is the first part of a mime.
Example 1):
Content-Type: text/plain; charset=us-ascii
where:
- text/plain is the media type
- and charset is the character set
Plugin
A user agent must not consider the types text/plain and application/octet-stream as having a registered plugin.
Registry
See the registry
List
For a full list, see the registry
Example:
audio/mpeg
image/gif
image/jpeg
text/css
text/html
text/javascript
video/mpeg
video/quicktime
Html
- text/html: HTML document
XML
The term XML MIME type is used to refer to the MIME types:
- text/xml,
- application/xml,
- and any MIME type whose subtype ends with the four characters “+xml”.
x-www-form-urlencoded
Media Type - x-www-form-urlencoded
Detection
You can detect it:
- by reading the file extension (ie txt, csv, …)
- or by parsing the content
- or via its magic number
Library
Java: probeContentType