History |
Using MIME to render files
The MIME Types file
Multipurpose Internet Mail Extensions (MIME) is a specification for formatting documents and messages so they can be sent over the Internet. These documents include server-parsed files and many non-html files such as:
• graphics
• audio
• video.
Internet Services maps file extensions and Macintosh type and Macintosh creator information to the MIME Types file. You can open this file with any ASCII editor (for example Notepad (Windows) or SimpleText (Mac)).
You can use the MIME Types file to:
• associate file types with particular programs
• render non-template documents
• enable browsers to display files that are not in HTML format
• inform Internet Services of which types of files to parse.
The MIME Types file can be stored in the Internet Services folder (or cluster equivalent) on the administrator's Desktop or in the FCServer/Config folder on your hard disk. If you store this file on the administrator's Desktop you can access it remotely. The server file overrides the file in the Config folder, if both are present.
Although you can make changes to your existing MIME Types file, it is usually not necessary for most standard FirstClass systems. By default, the Internet Services MIME Types file is configured to handle most widely used file extensions.
Associating file types with programs
The most common use of the MIME Types file is to associate file types with programs. The standard length for both the Macintosh file type and Macintosh file creator names is four characters. If you have less than four characters, you must use double quotes ("") around the entry and put spaces in for missing characters (for example, "mp3 ").
If no MIMETypes data is available, Internet Services maps the filename extension to the equivalent Macintosh file type/file creator values based on a FILETYPES record. FILETYPES is a built-in table of well-known extensions, file type and creator information, and icon ids. This is a fallback facility if the information is not found in the MIME Types document.
Associating icons with programs
The FILETYPES table contains the default icon ID to use for many file extensions. You can override this default by adding a new icon ID to the end of the associated line in the MIME Types document.
For example, if you prefer to associate Microsoft Word documents with icon ID 1234 instead of the default 9620, you can edit the associated line in the MIME Types document as follows:
application/msword W6BN MSWD .doc 1234
MIME Types file syntax
The basic MIME Types file syntax is:
mime type/subtype<tab>Mac type<tab>Mac creator<tab>filename extension [<tab>attachment icon id]
where,
mime type is the type of file
subtype is the subtype of the file
<tab> is a space
Mac type is the Macintosh file type
Mac creator is the browser type
filename extension is the extension of the file
attachment icon id is the icon id to associate with this file type if you wish to override the default icon id. Optional.
In keeping with the above syntax, a standard MIME type entry might be:
text/html<tab>TEXT<tab>MSIE<tab>.html
This entry causes all files with a .html extension to be sent to the browser directly.
For video files, you could enter this line of code in the MIME Types file:
video/mpeg MPEG mMPG .mpeg
This entry causes all files with a .mpeg extension to be sent to the browser directly.
Although it is a good idea to put entries in for each variable in the MIME type syntax, the most important entries are the mime type, subtype, and filename extension. These entries must be entered for the MIME type code to work. You can enter question marks (?) for the Mac type and Mac creator variables, for example:
audio/basic ???? ???? .snd
where this entry specifies a basic audio file with the .snd extension, and both Mac type and Mac creator can be anything, as designated by the question mark (?).
Although there are many predefined MIME Types, such as GIF graphics files and PostScript files, you can also define your own, by adding a line for each in the MIME Types file. Some commonly used file extensions are:
• .shtml, .shtm, .shm, .inc
• .swm, .swmls, .wml
• .png, .pict, .bmp
• .txt
• .css.
Rendering non-template documents
The MIME Types file can also be used to determine which non-template documents to render.
Typically, when a FirstClass web document is opened, a template is used to render it. However, you may want to create web pages using HTML, or some other markup language such as Extensible Markup Language (XML), to display content on your web site. Internet Services must have a way of sending these files to a browser without using templates. You can accomplish this by associating document extensions with specific file types.
Markup language documents
For HTML documents, you could enter this line of code in the MIME Types file:
text/html<tab>TEXT<tab>MSIE<tab>.html
This entry causes all files with an .html extension to be sent to the browser directly.
Non-standard extensions
If you have inherited HTML pages with a nonstandard extension that you want to maintain, for example .wws, you could enter this line of code in the MIME Types file:
text/html<tab>TEXT<tab>MSIE<tab>.wws
This entry causes all files with a .wws extension to be sent to the browser directly.
Enabling browsers to identify non-HTML files
You can use the MIME Types file to enable browsers to identify non-html files and do something with them instead of just saving them to disk (for example, audio and video files). A typical entry might be:
audio/mp3<tab>"MP3 "<tab>????<tab>.mp3
where,
audio is the file type
mp3 is the subtype of this file, "MP3 " is the Macintosh type (using less than four characters)
???? designates any browser
.mp3 is the filename extension.
Rendering server-parsed files
You can also configure the MIME Types file to choose which files should be server parsed. Server-parsed files are dynamic web documents (.shtml extension) that are sent to the server before they are displayed by a browser. This is different from static web documents (.html) that are displayed by a browser without passing through the server.
When a browser calls a page, Internet Services sends any server-parsed files that need to be displayed to the FirstClass server for processing. After processing is complete, the FirstClass server sends the file back to Internet Services, which then forwards it to the browser to display.
Examples of server-parsed files are:
• files with .shtml extensions
• Internet Services web templates
• any documents that include Internet Services script in the code.
Here are examples of MIME type entries for server-parsed files:
• text/x-server-parsed-html TEXT MOSS .shtml
• text/x-server-parsed-html TEXT MOSS .shm
• text/x-server-parsed-html TEXT MOSS .inc
MOSS is the Macintosh Creator code for Netscape.
These lines of code identify any html file with extensions .shtml, .shm, or .inc as server-parsed files.
| ||