What is a MIME type and how can you declare it?

Written by Alex Marin · July 28th, 2023

In the world of digital communication, being able to correctly identify and interpret different types of data files is crucial.

One technology that enables this is Multipurpose Internet Mail Extensions (MIME) Types. These identifiers are used to specify the nature and format of a file, aiding in the correct handling and display of the content.

This article provides an in-depth exploration of MIME Types, their structure, their location in the Windows registry, and how to efficiently manage them using Advanced Installer.

Breaking Down MIME Types: Their Structure and Use

MIME (Multipurpose Internet Mail Extension) Types are two-part identifiers for file formats and contents which are transmitted online.

A MIME Type, also known as internet media type, is formed as a tree which consists of a type and subtype, optionally you can also define a suffix and parameters.

We can think of a MIME Type as a label used to identify a certain type of data.

A real-life example would be:

  • The server says “This is an application/pdf”’
  • The client understands that “I need to launch the associated PDF program that the user has installed and it’s registered as the application/pdf handler”.

To illustrate this, let’s take the MIME Type for a PDF file as: application/pdf. Here, application represents the type and pdf is the subtype.

To further elaborate, the MIME Type syntax can be broken downas follows:

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

These are standardized and publicized by a local authority, the Internet Assigned Numbers Authority (IANA) in this case.

In the context of the Windows operating system, MIME Types are stored within the registry under these specific paths:

- Machine level database:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MIME\Database

- User Level database:

HKEY_CURRENT_USER\Software\Classes\MIME\DataBase

As I mentioned in MSI Packaging book, the classes machine level and user level trees are merged and exposed under the following path:

HKEY_CLASSES_ROOT\MIME\Database

The content type mappings are located under the Content Type subkey. For instance, the MIME Type for a PDF (application/pdf) can be found at this registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MIME\Database\Content Type\application/pdf

The default file extension is in the Extension value, which in our case is .PDF.

If we go to the Classes tree and search for the .pdf extension, we can see Acrobat.exe mentioned under the OpenWithList. If we have a look over the Class, we can see the application/pdf under the Content type value. This lets us know that this extension is using that MIME Type.

How to handle MIME Types with Advanced Installer

If you want to declare a MIME Type for a specific extension in your package, Advanced Installer makes it quite simple.

  1. Navigate to the File Associations Page.
  2. There, click on New Extension and define the extension.
  3. The option to define the MIME Type also appears on this screen.
define the MIME Type

ImportantDuring the installation of a MIME type, Windows Installer also registers the MIME type under the Internet Explorer MIME Database ("HKEY_CLASSES_ROOT\MIME\Database\Content Type" registry key). Considering how Internet Explorer handles MIME Types, it is not recommended to register the "application/octet-stream" MIME type with your application extension. This is because after registering the "application/octet-stream" MIME type with your application extension, Internet Explorer could associate all downloaded files of "application/octet-stream" MIME type with your application extension.

Ready to enhance your packaging workflow? Try Advanced Installer with a 30-day free trial.

Conclusion

To sum up, MIME Types act as crucial translators in the world of digital communication. They allow different programs to correctly interpret and handle specific file types.

From their location in the Windows registry to the structure of their syntax, understanding MIME Types is a key skill for any software or application packager.

Fortunately, tools like Advanced Installer simplify the process, making it easy to declare and manage MIME Types within your package.

So whether you're packaging an application or looking to ensure accurate data handling, understanding and utilizing MIME Types can play a significant role in your success.

Written by
See author's page
Alex Marin

Application Packaging and SCCM Deployments specialist, solutions finder, Technical Writer at Advanced Installer.

Comments: