[thelist] MIME types and CFCONTENT

Oliver Lineham oliver at lineham.co.nz
Sat Dec 16 19:54:52 CST 2000


hi. is this thing on? righto.  ahem.


i'm writing something in CF that lets people upload and download files from 
a site.  the files are not accessible directly, rather they are returned to 
the user with the CFCONTENT tag.


[aside (feel free to skip this):  we all know IE is wack when it comes to 
handling MIME types.  i've noticed if i return to the user a file with the 
"application/msword" content type header set, IE only fires up Word if the 
URL ends in .doc, otherwise it shows the binary data.  Yet it does know 
it's an MS Word document because the File>Properties dialog says "Microsoft 
Word document" despite showing garbage data as if it were a text file.  i 
don't mind, i'm going to be ending the URL in a nice suffix anyway.]


anyway, to digress.  this uploader/downloader must be filetype 
non-specific. it must be able to handle any type. ms word, pdf, jpeg, anything.

if the file were being downloaded directly, the web server (apache or IIS) 
would look up the suffix and generate an appropriate content type.

with cfcontent, it's not so easy. it needs to be told the content type.


what is the best way to do this?


i'm thinking of stealing the apache mime.types file and having my cf app 
look up suffixes in that.  but this seems a bit redundant seeing as the 
server should know what the MIME type is itself.

another option is to record the MIME type originally sent from the browser 
when the file was first uploaded (with CFFILE) and return this when it is 
downloaded. but do i really trust the browser?


is there a better way?


</ol>

____________________________________________________
     v i b e   m e d i a    http://www.vibe.co.nz/
  po box 10-492              wellington, new zealand
  phone +64 21 210-7845         oliver at lineham.co.nz




More information about the thelist mailing list