Curl/Bash code for Mime Type ExampleThis Curl/Bash code snippet was generated automatically for the Mime Type example.
<< Back to the Mime Type example
What is MIME Type?
MIME stands for Multipurpose Internet Mail Extensions.It is a fundamental part of communication protocols such as HTTP. The MIME type is required when you need to transfer non-text data. MIME was originally designed to extend the capabilities of email to support more data types such as non-ASCII text files and binary files such as images, PDFs, and executables. The use of MIME is not limited to email. It is now actively used in all communications over the Internet to describe the type of data sent to or from a server. It is often referred to as a media type or MIME content type. In HTTP, the MIME-type is part of the Content-Type header of an HTTP message and defines the data type in the body of an HTTP request or response. Setting the correct MIME data type in the body of the message is critical for both HTTP requests and responses and allows you to control how the request is interpreted by the client and server. Web servers and browsers have a list of well-known file extensions and MIME types. This helps them identify and interpret all known file types, regardless of the operating system and hardware used by the user.
MIME types usually have three parts: type, subtype, and additional media type parameters. For example, text/plain; charset=UTF-8 describes data in plain text format with UTF-8 encoding.
How to pass multiple objects in a single MIME message?
The MIME format supports the transmission of multiple objects in one message. Entities can be transferred not only in the form of a single-level sequence but also in the form of a hierarchy with the nesting of elements into each other. The multipart/* media type is used to indicate multiple contents. To transmit a multipart message, a boundary parameter is added to the Content-Type header, which denotes the sequence of characters that separate the parts of the message. The border can consist of numbers, letters, and symbols () + _, -. /: = ?.
The beginning of each part of the message is indicated by the string --boundary. The end of the last message is indicated by the string --boundary--. At the very beginning of the included part, there are headers that describe its content (Content-Type, Content-Length, etc.). If Content-Type is not specified, then text/plain is used by default.
Common MIME Types
The IANA is the official registry of MIME media types and maintains a list of all known official MIME types. Below is a short list of popular MIME types for the Internet.
- Images: image/jpeg, image/png, image/gif, image/svg+xml
- Files: text/plain, application/pdf, application/zip
- Applications: application/octet-stream, application/pkcs8
- Media: audio/mpeg, video/mp4, video/mpeg
- Data: application/json, application/xml