Add a new MIME Type

by Stephane Plante last modified Dec 30, 2008 03:03 PM
This How-to will traverse the steps required in order to add a MIME type in Plone. By consequence, it is also a How-to get Plone to treat Microsoft Project files properly.

Symptoms include mishandled or misreported file extension and/or association mapping to expected MIME type content. For example: after uploading a Microsoft Project Document (*.mpp) in Plone, it shows up as a Word document (*.doc) or some other unexpected file type.

Out-of-box Plone supports a common, wide range of MIME types, including documents from the Microsoft Office suite of applications. Files from the supplemental Office application Microsoft Project are currently not among these initial mime types.

First, some standard info regarding my system:

  • Plone 2.5.1
  • CMF-1.6.2
  • Zope (Zope 2.9.5-final, python 2.4.3, linux2)
  • Five 1.3.7
  • Python 2.4.3 (#1, Oct 27 2006, 15:02:49) [GCC 3.4.5 20051201 (Red Hat 3.4.5-2)]
  • PIL 1.1.5
  • RHEL 4.2


Add a new MIME type via the Zope Management Iterface (ZMI)

For the sake of this How-to, we will presume that your Plone deployment is rooted at /plone and the MIME content type you'd like to add is the Microsoft Project Document.

From the ZMI, navigate to /plone/mimetypes_registry and click Add a new MIME type.

Use the following information for the next page:

Name - Microsoft Project Document
Icon path - mpp.png (see below for more information on uploading this icon)
Binary? - Make sure it's checked

Mime-types - (it takes two lines)
application/x-project
application/vnd.ms-project

Extensions - (it takes four lines)
mpp
mpt
mpv
mpx

Globs - *.mpp

You do not need to restart your Zope instance if you add a MIME type (in either production or debug mode).

Click Submit Query and you've added the new MIME type.


Adding MIME Type Icons

MIME icons are stored in /plone/portal_skins/mimetypes_icons. You'll need to upload new icon files into the custom folder, /plone/portal_skins/custom.
These icon files must be PNG format, and to be consistent with formatting must also be 16x16 pixels in size.

To add the mpp.png icon, navigate to /plone/portal_skins/custom via the ZMI.

From the custom folder, select File (just 'File') from the drop-down list.

If no new page opens, make sure that File is selected and click Add. Use the following info for the next page:

Id - mpp.png
Title - Microsoft Project File Icon
File - Click Browse to visit the location to where the desired icon exists

Click Add when done. 

You should now see mpp.png in the /plone/portal_skins/custom folder.


Some Helpful Resources and Hints


Nothing works -


Review all of your settings with the steps above and consider the remaining hints that follow.

MIME type not updated for existing files -


If you or your user would rather not remove and upload the file again from within Plone (perhaps there is version history via CMFEditions that you need to preserve), edit the metadata of the file in question:
  • From the ZMI, navigate to the file in question
  • Select the Dublin Core tab (should already be there by default), update the Format field to the correct MIME type
  • Click Change

In the case of a Microsoft Project Document masquerading as a Microsoft Word Document, update the Format to application/x-project (instead of application/ms-word).

My MIME type icon doesn't display -


Make sure the Id of the mime type icon file in portal_skins/custom matches that of your Icon path specification in the MIME type (above). 

Your icon must be in PNG format,  and should be 16x16 pixels in size for the sake of formatting (unless a non-standard size is desired).

To find your MIME type -


FYI: Google Search results for 'mime type listing'.  I found a useful table on Webmaster Toolkit.

To determine a complete list of file extensions - 


I am presuming that you at least know of one file extension.  For a more complete listing, you may search for it online or consult the registered file types of your application.

You can generally do this by opening a 'file open' (or save, import/export) dialog and looking at the selectable file types from within the application.

Getting your MIME type icon -


Generally, these icons are available with the associated application.  You may search for a suitable icon online, noting copyright restrictions where they may apply.  You may use your favourite image editing program, such as GIMP or even Microsoft Paint to manipulate and save most images to 16x16 pixels in PNG format.

You may always create your own and find that inner Picasso at the same time... <G>