Adding a Mime Type

Showing results for 
Search instead for 
Did you mean: 

Adding a Mime Type

0 0 4,753

Obsolete Pages{{Obsolete}}

The official documentation is at:

Mime Type

Back to Server Configuration


Adding additional Mime Types to the repository

By default, there are two files that currently contain mimetype definitions:

  • mimetype-map.xml
  • mimetype-map-openoffice.xml

These are contained within the alfresco.war->repository.jar and should not be edited directly.

Mimetype Map files

Mimetypes are defined in XML in 'mimetype-map files. These contain definitions for one or more mimetype, featuring the display name for the mimetype, and any file extensions it uses. The file is of the form:

 <alfresco-config area='mimetype-map'>
  <config evaluator='string-compare' condition='Mimetype Map'>
        <mimetype mimetype='application/test' display='Example mimetype'>
        <mimetype mimetype='application/test2' display='Another example'>
            <extension default='true'>ex2</extension>

For more advanced file type detection than offered by file extensions alone, you should consider additionally defining your Mimetype to Apache Tika, and supplying custom Mime Magic for detection. See Adding Your MIME-Type for details on how to define custom mimetypes to Tika.

Adding additional Mimetype maps - Alfresco 3.x, 4.0

Instead, of editing the core mimetype files, override the mimetypeConfigService bean in an extension file, such as <extension>/alfresco/extension/custom-services-context.xml.

    <bean id='mimetypeConfigService' class='org.alfresco.config.xml.XMLConfigService' init-method='init'>
            <bean class='org.alfresco.config.source.UrlConfigSource'>

An example context file that does this is supplied in alfresco/extension/mimetype-map-extension-context.xml.sample

The UrlConfigService can load additional files such as:

  • classpath:alfresco/mimetype/mimetype-custom-extensions.xml - the file is in the app server's shared classpath location
  • file:/home/alfresco/conf/alfresco/mimetype/mimetype-custom-extensions.xml - the file is outside the server classpath locations

Any number of additional files can be added to the list.

Before Alfresco 4.0.1, Share did not retrieve its list of mimetypes directly from Alfresco but processes them within alfresco\site-webscripts\org\alfresco\components\form\controls\mimetype.ftl. This file either needs to be updated to include your new mimetypes, or the instructions under the bug ticket should be followed, or you should upgrade to 4.0.1 for the fix.

Adding additional Mimetype maps - Alfresco 4.0.1 and later

This applies to Alfresco 4.0.1 and later, and Alfresco Community builds from r33865 onwards

To make including additional Mimetype Maps easier, Alfresco 4.0.1 has changed to automatically loading extension mimetype maps that match a filename. This mirrors the extension behaviour in other areas of Alfresco.

To have your map loaded, place it into the alfresco/extension/mimetype/ directory, with a name that ends with -map.xml . An example file is provided as alfresco/extension/mimetype/mimetypes-extension-map.xml.sample . Multiple files may be included this way.

If the file format for which you are adding the mimetype builds on top of one of the well-known filetypes already supported by both Alfresco and Apache Tika, you may wish to also add the mimetype to Apache Tika complete with the mimetypes hierarchy information. To do that, create a file org/apache/tika/mime/custom-mimetypes.xml and populate it with details of your mimetypes, in the FreeDesktop MIME-Info format. As an example, this what you'd add for a custom mimetype which is based on a zip file structure:

<mime-type type='application/x-my-custom-zip-format'>
   <_comment>My custom format which is built on top of ZIP</_comment>
   <glob pattern='*.myformat' />

PS: To add mimetype custom mapping in a packaging (AMP or JAR), you should use the file: /META-INF/mimetype/mimetype-map-custom.xml.