FTP type proposed solution..

From: Trevor Paquette <tpaquett@dont-contact.us>
Date: Mon, 24 Feb 1997 22:02:44 -0700

I think I know how to make everyone happy..

- check the file extension against an external mime.types files.
        - if it exists.. set it accordingly

(Now the good stuff)
ELSE

if you cannot find a MIME type from the above.. extract the first X bytes
from the file. Scan the bytes looking for a character with the high bit set.

If you find one byte with the high bit set, then set the MIME type to
application/octet-stream.

If you do not find one, assume text/plain.

Simple, yet will solve 95% of all the files out there. I have used this before
in trying to determine if a file is binary or not, and I have only had it fail
twice. I set 'X' to the first 256 bytes of the file.

Can do?

--
Trevor Paquette              |MetroNet Solutions Inc. |Work:(403)543-2355
TrevorPaquette@mcc.net       |  2700, 421 7th Ave SW  | Fax:(403)543-2854
http://www.nsci.net          |  Calgary, Ab, Canada   |ICBM:51'05"N/114'01"W
Senior Unix Network Architect|        T2P 4K9         |Mind:In the Rockies
Received on Mon Feb 24 1997 - 21:12:31 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:34:32 MST