Configuring MIME types for Files
You can assign Multipurpose Internet Mail Extensions (MIME) types to file extensions.
Before you begin
To edit configuration files, you must use the IBM® WebSphere® Application Server wsadmin client. See Starting the wsadmin client for information about how to start the wsadmin command-line tool.
About this task
You can configure Files to assign a specific MIME type to files with specific extensions. Files with MIME types tell operating systems what applications to open them with, and what applications to display in file open windows. MIME types make it easier for users at a glance to know what type of data a file contains. Also, some applications do not download files that do not have a MIME type that they support.
This configuration applies to files uploaded through the web user interface. The configuration is ignored if a third party application assigns MIME types to extensions using the API.
You can also map extensions to icons. See the topic Customizing file type icons.
Procedure
- Start the wsadmin client.
- Start the Files Jython script interpreter.
- Navigate to the working directory specified in Step 2b
and open the
mime-files-config.xml
file. The contents look like this:<mapping mimeType="..." mediaType="..."> <extension></extension> <extension></extension> .... </mapping>
- In the mimeType attribute specify a
mime type in standard format, for example
text/plain
. Each value must be unique compared with other mimeType values in other mapping elements, or an error is returned when you start the system. See the Internet Assigned Numbers Authority (IANA) web site for a list of MIME types.For example, using the<extension openFromWeb="true">jpg</extension>
entry displays an Open this file button in the Files user interface for files that have the .jpg file extension. This allows users to directly open this file type in their in browser, provided that their browser supports this action.
In this example, files with an extension of .jpg will have mime-type of image/jpeg. The openFromWeb setting indicates whether this file can be opened directly in browser. This attribute only takes effect when security.inlineDownload.enabled is true.<mapping mediaType="image" mimeType="image/jpeg"> <extension>jpe</extension> <extension openFromWeb="true">jpeg</extension> <extension openFromWeb="true">jpg</extension> </mapping>
- In each extension element specify the extensions that you want to map to the MIME type. Each value must be unique compared with other extension elements in the configuration file, or an error is returned when you start the system.
- Apply the changes following steps in the Applying Files property changes.
Example
<mapping mimeType="text/plain" mediaType="">
<extension>txt</extension>
....
</mapping>