Tuesday, January 19, 2010

How to add new MIME type


To add a new MIME type
Create following 2 files in alfresco/extension folder
1. custom-services-context.xml
2. mimetypes-custom-extension.xml

Add the following to the 1st file – custom-services-context.xml

<beans>
<bean id="mimetypeConfigService" class="org.alfresco.config.xml.XMLConfigService" init-method="init">
<constructor-arg>
<bean class="org.alfresco.config.source.UrlConfigSource">
<constructor-arg>
<list>
<value>classpath:alfresco/mimetype/mimetype-map.xml</value>
<value>classpath:alfresco/mimetype/mimetype-map-openoffice.xml</value>
<value>classpath:alfresco/extension/mimetypes-custom-extension.xml</value>
</list>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
</beans>

In the mimetypes-custom-extension.xml file define your new mime type here for an example - .abc

<alfresco-config area="mimetype-map">
<config evaluator="string-compare" condition="Mimetype Map">
<mimetypes>
<mimetype mimetype="application/abc" display="ABC File Type">
<extension default="true">abc</extension>
</mimetype>
</mimetypes>
</config>
</alfresco-config>

To test it, Restart your server