WebJoe
asked on
File type in ADODB.Stream
Hi Experts,
To offer visitors a download without giving away the path to the file, I implemented the code as described in Microsofts Knowledge Base article "Use of the ADODB.Stream Object to Send Binary Files to the Browser through ASP" (http://support.microsoft.com/support/kb/articles/q276/4/88.asp).
Most of the files I want to send are PDF, so I changed
Response.ContentType = "application/octet-stream"
to
Response.ContentType = "application/pdf"
Is there any way to set the mime type automatically?
To offer visitors a download without giving away the path to the file, I implemented the code as described in Microsofts Knowledge Base article "Use of the ADODB.Stream Object to Send Binary Files to the Browser through ASP" (http://support.microsoft.com/support/kb/articles/q276/4/88.asp).
Most of the files I want to send are PDF, so I changed
Response.ContentType = "application/octet-stream"
to
Response.ContentType = "application/pdf"
Is there any way to set the mime type automatically?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
so to have a (hopefully) correct content type, you'd have to do
<snip>
sFileExtension = UCase(Right(sFile, (Len(sFile) - InStrRev(sFile, ".", -1, vbTextCompare))))
' Set the content type and stream type according to file extension
Select Case sFileExtension
Case "3DM", "3DMF", "QD3", "QD3D"
sContentType = "x-world/x-3dmf"
Case "A", "ARC", "ARJ", "BIN", "COM", "DUMP", "EXE", "LHA", "LHX", "LZH", "LZX", "O", "PSD", "SAVEME", "ZOO"
sContentType = "application/octet-stream"
Case "AAB"
sContentType = "application/x-authorware- bin"
Case "AAM"
sContentType = "application/x-authorware- map"
Case "AAS"
sContentType = "application/x-authorware- seg"
Case "ABC"
sContentType = "text/vnd.abc"
Case "ACGI", "HTM", "HTML", "HTMLS", "HTX", "SHTML"
sContentType = "text/html"
Case "AFL"
sContentType = "video/animaflex"
Case "AI", "EPS", "PS"
sContentType = "application/postscript"
Case "AIF", "AIFC", "AIFF"
sContentType = "audio/aiff"
Case "AIM"
sContentType = "application/x-aim"
Case "AIP"
sContentType = "text/x-audiosoft-intra"
Case "ANI"
sContentType = "application/x-navi-animat ion"
Case "AOS"
sContentType = "application/x-nokia-9000- communicat or-add-on- software"
Case "APS"
sContentType = "application/mime"
Case "ART"
sContentType = "image/x-jg"
Case "ASM", "S"
sContentType = "text/x-asm"
Case "ASP"
sContentType = "text/asp"
Case "ASX", "ASF"
sContentType = "video/x-ms-asf "
Case "AU"
sContentType = "audio/x-au"
Case "AVI"
sContentType = "video/msvideo"
Case "AVS"
sContentType = "video/avs-video"
Case "BCPIO"
sContentType = "application/x-bcpio"
Case "BM", "BMP"
sContentType = "image/bmp"
Case "BMP"
sContentType = "image/x-windows-bmp"
Case "BOO", "BOOK"
sContentType = "application/book"
Case "BOZ", "BZ2"
sContentType = "application/x-bzip2"
Case "BSH", "SHAR"
sContentType = "application/x-bsh"
Case "BZ"
sContentType = "application/x-bzip"
Case "C", "C++", "CC", "CONF", "CXX", "DEF", "F", "F90", "FOR", "G", "H", "HH", "IDC", "JAV", "JAVA", "JS", "LIST", "LOG", "LST", "M", "MAR", "PL", "SDML", "TEXT", "TXT"
sContentType = "text/plain"
Case "CAT"
sContentType = "application/vnd.ms-pki.se ccat"
Case "CCAD"
sContentType = "application/clariscad"
Case "CCO"
sContentType = "application/x-cocoa"
Case "CDF"
sContentType = "application/cdf"
Case "CER", "CRT"
sContentType = "application/pkix-cert"
Case "CHA", "CHAT"
sContentType = "application/x-chat"
Case "CLASS"
sContentType = "application/java"
Case "CPIO"
sContentType = "application/x-cpio"
Case "CPP"
sContentType = "text/x-c"
Case "CPT"
sContentType = "application/mac-compactpr o"
Case "CRL"
sContentType = "application/pkix-crl"
Case "CSH"
sContentType = "application/x-csh"
Case "CSH"
sContentType = "text/x-script.csh"
Case "CSS"
sContentType = "text/css"
Case "DCR", "DIR", "DXR"
sContentType = "application/x-director"
Case "DEEPV"
sContentType = "application/x-deepv"
Case "DER"
sContentType = "application/x-x509-ca-cer t"
Case "DIF", "DV"
sContentType = "video/x-dv"
Case "DL"
sContentType = "video/dl"
Case "DOC", "DOT", "W6W", "WIZ", "WORD"
sContentType = "application/msword"
Case "DP"
sContentType = "application/commonground"
Case "DRW"
sContentType = "application/drafting"
Case "DVI"
sContentType = "application/x-dvi"
Case "DWF"
sContentType = "model/vnd.dwf"
Case "DWG", "DXF", "SVF"
sContentType = "image/vnd.dwg"
Case "EL"
sContentType = "text/x-script.elisp"
Case "ELC"
sContentType = "application/x-elc"
Case "ENV"
sContentType = "application/x-envoy"
Case "ES"
sContentType = "application/x-esrehber"
Case "ETX"
sContentType = "text/x-setext"
Case "EVY"
sContentType = "application/envoy"
Case "F77"
sContentType = "text/x-fortran"
Case "FDF"
sContentType = "application/vnd.fdf"
Case "FIF"
sContentType = "image/fif"
Case "FLI"
sContentType = "video/fli"
Case "FLO", "TURBOT image/florian"
Case "FLX"
sContentType = "text/vnd.fmi.flexstor"
Case "FMF"
sContentType = "video/x-atomic3d-feature"
Case "FPX"
sContentType = "image/vnd.fpx"
Case "FRL"
sContentType = "application/freeloader"
Case "FUNK", "MY", "PFUNK"
sContentType = "audio/make"
Case "G3"
sContentType = "image/g3fax"
Case "GIF"
sContentType = "image/gif"
Case "GL"
sContentType = "video/gl"
Case "GSD", "GSM"
sContentType = "audio/x-gsm"
Case "GSP"
sContentType = "application/x-gsp"
Case "GSS"
sContentType = "application/x-gss"
Case "GTAR"
sContentType = "application/x-gtar"
Case "GZ", "GZIP"
sContentType = "application/x-gzip"
Case "HDF"
sContentType = "application/x-hdf"
Case "HELP"
sContentType = "application/x-helpfile"
Case "HGL", "HPG", "HPGL"
sContentType = "application/vnd.hp-hpgl"
Case "HLB"
sContentType = "text/x-script"
Case "HLP"
sContentType = "application/hlp"
Case "HQX"
sContentType = "application/binhex"
Case "HTA"
sContentType = "application/hta"
Case "HTC"
sContentType = "text/x-component"
Case "HTT"
sContentType = "text/webviewhtml"
Case "ICE"
sContentType = "x-conference/x-cooltalk"
Case "ICO"
sContentType = "image/x-icon"
Case "IEF", "IEFS"
sContentType = "image/ief"
Case "IGES", "IGS"
sContentType = "model/iges"
Case "IMA"
sContentType = "application/x-ima"
Case "IMAP"
sContentType = "application/x-httpd-imap"
Case "INF"
sContentType = "application/inf"
Case "INS"
sContentType = "application/x-internett-s ignup"
Case "IP"
sContentType = "application/x-ip2"
Case "ISU"
sContentType = "video/x-isvideo"
Case "IT"
sContentType = "audio/it"
Case "IV"
sContentType = "application/x-inventor"
Case "IVR"
sContentType = "i-world/i-vrml"
Case "IVY"
sContentType = "application/x-livescreen"
Case "JAM"
sContentType = "audio/x-jam"
Case "JCM"
sContentType = "application/x-java-commer ce"
Case "JFIF", "JFIF-TBNL", "JPE", "JPEG", "JPG"
sContentType = "image/jpeg"
Case "JPS"
sContentType = "image/x-jps"
Case "JUT"
sContentType = "image/jutvision"
Case "KAR", "MID", "MIDI"
sContentType = "audio/midi"
Case "KSH"
sContentType = "text/x-script.ksh"
Case "LA"
sContentType = "audio/x-nspaudio"
Case "LA", "LMA"
sContentType = "audio/nspaudio"
Case "LAM"
sContentType = "audio/x-liveaudio"
Case "LATEX", "LTX"
sContentType = "application/x-latex"
Case "LSP"
sContentType = "text/x-script.lisp"
Case "LSX"
sContentType = "text/x-la-asf"
Case "M1V", "M2V", "MP2", "MP3", "MPA", "MPE", "MPEG", "MPG"
sContentType = "video/mpeg"
Case "M2A", "MP2", "MPGA"
sContentType = "audio/mpeg"
Case "M3U"
sContentType = "audio/x-mpequrl"
Case "MAN"
sContentType = "application/x-troff-man"
Case "MAP"
sContentType = "application/x-navimap"
Case "MBD"
sContentType = "application/mbedlet"
Case "MC$"
sContentType = "application/x-magic-cap-p ackage-1.0 "
Case "MCD"
sContentType = "application/mcad"
Case "MCF"
sContentType = "text/mcf"
Case "MCP"
sContentType = "application/netmc"
Case "ME"
sContentType = "application/x-troff-me"
Case "MHT", "MHTML", "MIME"
sContentType = "message/rfc822"
Case "MIF"
sContentType = "application/x-frame"
Case "MJF"
sContentType = "audio/x-vnd.audioexplosio n.mjuiceme diafile"
Case "MJPG"
sContentType = "video/x-motion-jpeg"
Case "MM", "MME"
sContentType = "application/base64"
Case "MOD"
sContentType = "audio/mod"
Case "MOOV", "MOV", "QT"
sContentType = "video/quicktime"
Case "MOVIE", "MV"
sContentType = "video/x-sgi-movie"
Case "MPC", "MPT", "MPV", "MPX"
sContentType = "application/x-project"
Case "MPP"
sContentType = "application/vnd.ms-projec t"
Case "MRC"
sContentType = "application/marc"
Case "MS"
sContentType = "application/x-troff-ms"
Case "MZZ"
sContentType = "application/x-vnd.audioex plosion.mz z"
Case "NAP", "NAPLPS image/naplps"
Case "NC"
sContentType = "application/x-netcdf"
Case "NCM"
sContentType = "application/vnd.nokia.con figuration -message"
Case "NIF", "NIFF"
sContentType = "image/x-niff"
Case "NIX"
sContentType = "application/x-mix-transfe r"
Case "NSC"
sContentType = "application/x-conference"
Case "NVD"
sContentType = "application/x-navidoc"
Case "ODA"
sContentType = "application/oda"
Case "OMC"
sContentType = "application/x-omc"
Case "OMCD"
sContentType = "application/x-omcdatamake r"
Case "OMCR"
sContentType = "application/x-omcregerato r"
Case "P"
sContentType = "text/x-pascal"
Case "P10"
sContentType = "application/pkcs10"
Case "P12"
sContentType = "application/pkcs-12"
Case "P7A"
sContentType = "application/x-pkcs7-signa ture"
Case "P7C", "P7M"
sContentType = "application/pkcs7-mime"
Case "P7R"
sContentType = "application/x-pkcs7-certr eqresp"
Case "P7S"
sContentType = "application/pkcs7-signatu re"
Case "PART", "PRT"
sContentType = "application/pro_eng"
Case "PAS"
sContentType = "text/pascal"
Case "PBM"
sContentType = "image/x-portable-bitmap"
Case "PCL"
sContentType = "application/vnd.hp-pcl"
Case "PCT"
sContentType = "image/x-pict"
Case "PCX"
sContentType = "image/x-pcx"
Case "PDB", "XYZ"
sContentType = "chemical/x-pdb"
Case "PDF"
sContentType = "application/pdf"
Case "PGM"
sContentType = "image/x-portable-greymap"
Case "PIC", "PICT"
sContentType = "image/pict"
Case "PKG"
sContentType = "application/x-newton-comp atible-pkg "
Case "PKO"
sContentType = "application/vnd.ms-pki.pk o"
Case "PLX"
sContentType = "application/x-pixclscript "
Case "PM"
sContentType = "text/x-script.perl-module "
Case "PM4", "PM5"
sContentType = "application/x-pagemaker"
Case "PNG", "X-PNG"
sContentType = "image/png"
Case "PNM"
sContentType = "image/x-portable-anymap"
Case "POT", "PPA", "PPS", "PPT", "PPZ", "PWZ"
sContentType = "application/powerpoint"
Case "POV"
sContentType = "model/x-pov"
Case "PPM"
sContentType = "image/x-portable-pixmap"
Case "PRE"
sContentType = "application/x-freelance"
Case "PVU"
sContentType = "paleovu/x-pv"
Case "PY"
sContentType = "text/x-script.phyton"
Case "PYC"
sContentType = "applicaiton/x-bytecode.py thon"
Case "QCP"
sContentType = "audio/vnd.qcelp"
Case "QIF", "QTI", "QTIF"
sContentType = "image/x-quicktime"
Case "QTC"
sContentType = "video/x-qtc"
Case "RA"
sContentType = "audio/x-realaudio"
Case "RA", "RAM", "RM", "RMM", "RMP"
sContentType = "audio/x-pn-realaudio"
Case "RAS", "RAST"
sContentType = "image/cmu-raster"
Case "REXX"
sContentType = "text/x-script.rexx"
Case "RF"
sContentType = "image/vnd.rn-realflash"
Case "RGB"
sContentType = "image/x-rgb"
Case "RMI"
sContentType = "audio/mid"
Case "RNG"
sContentType = "application/ringing-tones "
Case "RNX"
sContentType = "application/vnd.rn-realpl ayer"
Case "ROFF"
sContentType = "application/x-troff"
Case "RP"
sContentType = "image/vnd.rn-realpix"
Case "RPM"
sContentType = "audio/x-pn-realaudio-plug in"
Case "RT", "RTF", "RTX"
sContentType = "text/richtext"
Case "RV"
sContentType = "video/vnd.rn-realvideo"
Case "S3M"
sContentType = "audio/s3m"
Case "SBK"
sContentType = "application/x-tbook"
Case "SCM"
sContentType = "application/x-lotusscreen cam"
Case "SDP"
sContentType = "application/sdp"
Case "SDR"
sContentType = "application/sounder"
Case "SEA"
sContentType = "application/sea"
Case "SET"
sContentType = "application/set"
Case "SGM", "SGML"
sContentType = "text/sgml"
Case "SH"
sContentType = "application/x-sh"
Case "SID"
sContentType = "audio/x-psid"
Case "SIT"
sContentType = "application/x-sit"
Case "SKD", "SKM", "SKP", "SKT"
sContentType = "application/x-koan"
Case "SL"
sContentType = "application/x-seelogo"
Case "SMI", "SMIL"
sContentType = "application/smil"
Case "SND"
sContentType = "audio/basic"
Case "SOL"
sContentType = "application/solids"
Case "SPC"
sContentType = "application/x-pkcs7-certi ficates"
Case "SPL"
sContentType = "application/futuresplash"
Case "SPR", "SPRITE application/x-sprite"
Case "SRC", "WSRC"
sContentType = "application/x-wais-source "
Case "SSI"
sContentType = "text/x-server-parsed-html "
Case "SSM"
sContentType = "application/streamingmedi a"
Case "SST"
sContentType = "application/vnd.ms-pki.ce rtstore"
Case "STEP", "STP"
sContentType = "application/step"
Case "STL"
sContentType = "application/sla"
Case "SV4CPIO application/x-sv4cpio"
Case "SV4CRC application/x-sv4crc"
Case "SVR"
sContentType = "application/x-world"
Case "SWF"
sContentType = "application/x-shockwave-f lash"
Case "T"
sContentType = "application/x-troff"
Case "TALK"
sContentType = "text/x-speech"
Case "TAR"
sContentType = "application/x-tar"
Case "TBK"
sContentType = "application/toolbook"
Case "TCL"
sContentType = "application/x-tcl"
Case "TCSH"
sContentType = "text/x-script.tcsh"
Case "TEX"
sContentType = "application/x-tex"
Case "TEXI", "TEXINFO application/x-texinfo"
Case "TGZ"
sContentType = "application/gnutar"
Case "TIF", "TIFF"
sContentType = "image/tiff"
Case "TR"
sContentType = "application/x-troff"
Case "TSI"
sContentType = "audio/tsp-audio"
Case "TSP"
sContentType = "audio/tsplayer"
Case "TSV"
sContentType = "text/tab-separated-values "
Case "UIL"
sContentType = "text/x-uil"
Case "UNI", "UNIS", "URI", "URIS"
sContentType = "text/uri-list"
Case "UNV"
sContentType = "application/i-deas"
Case "USTAR"
sContentType = "application/x-ustar"
Case "UU", "UUE"
sContentType = "text/x-uuencode"
Case "VCD"
sContentType = "application/x-cdlink"
Case "VCS"
sContentType = "text/x-vcalendar"
Case "VDA"
sContentType = "application/vda"
Case "VDO"
sContentType = "video/vdo"
Case "VEW"
sContentType = "application/groupwise"
Case "VIV", "VIVO"
sContentType = "video/vivo"
Case "VMD"
sContentType = "application/vocaltec-medi a-desc"
Case "VMF"
sContentType = "application/vocaltec-medi a-file"
Case "VOC"
sContentType = "audio/voc"
Case "VOS"
sContentType = "video/vosaic"
Case "VOX"
sContentType = "audio/voxware"
Case "VQE", "VQL"
sContentType = "audio/x-twinvq-plugin"
Case "VQF"
sContentType = "audio/x-twinvq"
Case "VRML", "WRL", "WRZ"
sContentType = "model/vrml"
Case "VRT"
sContentType = "x-world/x-vrt"
Case "VSD", "VST", "VSW"
sContentType = "application/x-visio"
Case "W60"
sContentType = "application/wordperfect6. 0"
Case "W61"
sContentType = "application/wordperfect6. 1"
Case "WAV"
sContentType = "audio/wav"
Case "WAX"
sContentType = "audio/x-ms-wax "
Case "WB1"
sContentType = "application/x-qpro"
Case "WBMP"
sContentType = "image/vnd.wap.wbmp"
Case "WEB"
sContentType = "application/vnd.xara"
Case "WK1"
sContentType = "application/x-123"
Case "WM"
sContentType = "video/x-ms-wm "
Case "WMA"
sContentType = "audio/x-ms-wma "
Case "WMD"
sContentType = "application/x-ms-wmd "
Case "WMF"
sContentType = "windows/metafile"
Case "WML"
sContentType = "text/vnd.wap.wml"
Case "WMLC"
sContentType = "application/vnd.wap.wmlc"
Case "WMLS"
sContentType = "text/vnd.wap.wmlscript"
Case "WMLSC"
sContentType = "application/vnd.wap.wmlsc riptc"
Case "WMV"
sContentType = "video/x-ms-wmv "
Case "WMX"
sContentType = "video/x-ms-wmx "
Case "WMZ"
sContentType = "application/x-ms-wmz "
Case "WP", "WP5", "WP6", "WPD"
sContentType = "application/wordperfect"
Case "WQ1"
sContentType = "application/x-lotus"
Case "WRI"
sContentType = "application/mswrite"
Case "WSC"
sContentType = "text/scriplet"
Case "WTK"
sContentType = "application/x-wintalk"
Case "WVX"
sContentType = "video/x-ms-wvx "
Case "XBM", "XPM"
sContentType = "image/xpm"
Case "XDR"
sContentType = "video/x-amt-demorun"
Case "XGZ"
sContentType = "xgl/drawing"
Case "XIF"
sContentType = "image/vnd.xiff"
Case "XL", "XLA", "XLB", "XLC", "XLD", "XLK", "XLL", "XLM", "XLS", "XLT", "XLV", "XLW"
sContentType = "application/excel"
Case "XM"
sContentType = "audio/xm"
Case "XML"
sContentType = "application/xml"
Case "XMZ"
sContentType = "xgl/movie"
Case "XPIX"
sContentType = "application/x-vnd.ls-xpix "
Case "XSR"
sContentType = "video/x-amt-showrun"
Case "XWD"
sContentType = "image/x-xwd"
Case "Z"
sContentType = "application/x-compressed"
Case "ZIP"
sContentType = "application/zip"
Case "ZSH"
sContentType = "text/x-script.zsh"
Case Else
sContentType = "application/octet-stream"
End Select
If Left(sContentType, InStr(1, sContentType, "/", vbTextCompare) - 1) Then
lStreamType = adTypeText
Else
lStreamType = adTypeBinary
End If
Response.ContentType = sContentType
' open a stream
Set objStream = Server.CreateObject("ADODB .Stream")
objStream.Open
' set type
objStream.Type = lStreamType
<snip>
(assuption: variables DIMed, adType-constants defined)
<snip>
sFileExtension = UCase(Right(sFile, (Len(sFile) - InStrRev(sFile, ".", -1, vbTextCompare))))
' Set the content type and stream type according to file extension
Select Case sFileExtension
Case "3DM", "3DMF", "QD3", "QD3D"
sContentType = "x-world/x-3dmf"
Case "A", "ARC", "ARJ", "BIN", "COM", "DUMP", "EXE", "LHA", "LHX", "LZH", "LZX", "O", "PSD", "SAVEME", "ZOO"
sContentType = "application/octet-stream"
Case "AAB"
sContentType = "application/x-authorware-
Case "AAM"
sContentType = "application/x-authorware-
Case "AAS"
sContentType = "application/x-authorware-
Case "ABC"
sContentType = "text/vnd.abc"
Case "ACGI", "HTM", "HTML", "HTMLS", "HTX", "SHTML"
sContentType = "text/html"
Case "AFL"
sContentType = "video/animaflex"
Case "AI", "EPS", "PS"
sContentType = "application/postscript"
Case "AIF", "AIFC", "AIFF"
sContentType = "audio/aiff"
Case "AIM"
sContentType = "application/x-aim"
Case "AIP"
sContentType = "text/x-audiosoft-intra"
Case "ANI"
sContentType = "application/x-navi-animat
Case "AOS"
sContentType = "application/x-nokia-9000-
Case "APS"
sContentType = "application/mime"
Case "ART"
sContentType = "image/x-jg"
Case "ASM", "S"
sContentType = "text/x-asm"
Case "ASP"
sContentType = "text/asp"
Case "ASX", "ASF"
sContentType = "video/x-ms-asf "
Case "AU"
sContentType = "audio/x-au"
Case "AVI"
sContentType = "video/msvideo"
Case "AVS"
sContentType = "video/avs-video"
Case "BCPIO"
sContentType = "application/x-bcpio"
Case "BM", "BMP"
sContentType = "image/bmp"
Case "BMP"
sContentType = "image/x-windows-bmp"
Case "BOO", "BOOK"
sContentType = "application/book"
Case "BOZ", "BZ2"
sContentType = "application/x-bzip2"
Case "BSH", "SHAR"
sContentType = "application/x-bsh"
Case "BZ"
sContentType = "application/x-bzip"
Case "C", "C++", "CC", "CONF", "CXX", "DEF", "F", "F90", "FOR", "G", "H", "HH", "IDC", "JAV", "JAVA", "JS", "LIST", "LOG", "LST", "M", "MAR", "PL", "SDML", "TEXT", "TXT"
sContentType = "text/plain"
Case "CAT"
sContentType = "application/vnd.ms-pki.se
Case "CCAD"
sContentType = "application/clariscad"
Case "CCO"
sContentType = "application/x-cocoa"
Case "CDF"
sContentType = "application/cdf"
Case "CER", "CRT"
sContentType = "application/pkix-cert"
Case "CHA", "CHAT"
sContentType = "application/x-chat"
Case "CLASS"
sContentType = "application/java"
Case "CPIO"
sContentType = "application/x-cpio"
Case "CPP"
sContentType = "text/x-c"
Case "CPT"
sContentType = "application/mac-compactpr
Case "CRL"
sContentType = "application/pkix-crl"
Case "CSH"
sContentType = "application/x-csh"
Case "CSH"
sContentType = "text/x-script.csh"
Case "CSS"
sContentType = "text/css"
Case "DCR", "DIR", "DXR"
sContentType = "application/x-director"
Case "DEEPV"
sContentType = "application/x-deepv"
Case "DER"
sContentType = "application/x-x509-ca-cer
Case "DIF", "DV"
sContentType = "video/x-dv"
Case "DL"
sContentType = "video/dl"
Case "DOC", "DOT", "W6W", "WIZ", "WORD"
sContentType = "application/msword"
Case "DP"
sContentType = "application/commonground"
Case "DRW"
sContentType = "application/drafting"
Case "DVI"
sContentType = "application/x-dvi"
Case "DWF"
sContentType = "model/vnd.dwf"
Case "DWG", "DXF", "SVF"
sContentType = "image/vnd.dwg"
Case "EL"
sContentType = "text/x-script.elisp"
Case "ELC"
sContentType = "application/x-elc"
Case "ENV"
sContentType = "application/x-envoy"
Case "ES"
sContentType = "application/x-esrehber"
Case "ETX"
sContentType = "text/x-setext"
Case "EVY"
sContentType = "application/envoy"
Case "F77"
sContentType = "text/x-fortran"
Case "FDF"
sContentType = "application/vnd.fdf"
Case "FIF"
sContentType = "image/fif"
Case "FLI"
sContentType = "video/fli"
Case "FLO", "TURBOT image/florian"
Case "FLX"
sContentType = "text/vnd.fmi.flexstor"
Case "FMF"
sContentType = "video/x-atomic3d-feature"
Case "FPX"
sContentType = "image/vnd.fpx"
Case "FRL"
sContentType = "application/freeloader"
Case "FUNK", "MY", "PFUNK"
sContentType = "audio/make"
Case "G3"
sContentType = "image/g3fax"
Case "GIF"
sContentType = "image/gif"
Case "GL"
sContentType = "video/gl"
Case "GSD", "GSM"
sContentType = "audio/x-gsm"
Case "GSP"
sContentType = "application/x-gsp"
Case "GSS"
sContentType = "application/x-gss"
Case "GTAR"
sContentType = "application/x-gtar"
Case "GZ", "GZIP"
sContentType = "application/x-gzip"
Case "HDF"
sContentType = "application/x-hdf"
Case "HELP"
sContentType = "application/x-helpfile"
Case "HGL", "HPG", "HPGL"
sContentType = "application/vnd.hp-hpgl"
Case "HLB"
sContentType = "text/x-script"
Case "HLP"
sContentType = "application/hlp"
Case "HQX"
sContentType = "application/binhex"
Case "HTA"
sContentType = "application/hta"
Case "HTC"
sContentType = "text/x-component"
Case "HTT"
sContentType = "text/webviewhtml"
Case "ICE"
sContentType = "x-conference/x-cooltalk"
Case "ICO"
sContentType = "image/x-icon"
Case "IEF", "IEFS"
sContentType = "image/ief"
Case "IGES", "IGS"
sContentType = "model/iges"
Case "IMA"
sContentType = "application/x-ima"
Case "IMAP"
sContentType = "application/x-httpd-imap"
Case "INF"
sContentType = "application/inf"
Case "INS"
sContentType = "application/x-internett-s
Case "IP"
sContentType = "application/x-ip2"
Case "ISU"
sContentType = "video/x-isvideo"
Case "IT"
sContentType = "audio/it"
Case "IV"
sContentType = "application/x-inventor"
Case "IVR"
sContentType = "i-world/i-vrml"
Case "IVY"
sContentType = "application/x-livescreen"
Case "JAM"
sContentType = "audio/x-jam"
Case "JCM"
sContentType = "application/x-java-commer
Case "JFIF", "JFIF-TBNL", "JPE", "JPEG", "JPG"
sContentType = "image/jpeg"
Case "JPS"
sContentType = "image/x-jps"
Case "JUT"
sContentType = "image/jutvision"
Case "KAR", "MID", "MIDI"
sContentType = "audio/midi"
Case "KSH"
sContentType = "text/x-script.ksh"
Case "LA"
sContentType = "audio/x-nspaudio"
Case "LA", "LMA"
sContentType = "audio/nspaudio"
Case "LAM"
sContentType = "audio/x-liveaudio"
Case "LATEX", "LTX"
sContentType = "application/x-latex"
Case "LSP"
sContentType = "text/x-script.lisp"
Case "LSX"
sContentType = "text/x-la-asf"
Case "M1V", "M2V", "MP2", "MP3", "MPA", "MPE", "MPEG", "MPG"
sContentType = "video/mpeg"
Case "M2A", "MP2", "MPGA"
sContentType = "audio/mpeg"
Case "M3U"
sContentType = "audio/x-mpequrl"
Case "MAN"
sContentType = "application/x-troff-man"
Case "MAP"
sContentType = "application/x-navimap"
Case "MBD"
sContentType = "application/mbedlet"
Case "MC$"
sContentType = "application/x-magic-cap-p
Case "MCD"
sContentType = "application/mcad"
Case "MCF"
sContentType = "text/mcf"
Case "MCP"
sContentType = "application/netmc"
Case "ME"
sContentType = "application/x-troff-me"
Case "MHT", "MHTML", "MIME"
sContentType = "message/rfc822"
Case "MIF"
sContentType = "application/x-frame"
Case "MJF"
sContentType = "audio/x-vnd.audioexplosio
Case "MJPG"
sContentType = "video/x-motion-jpeg"
Case "MM", "MME"
sContentType = "application/base64"
Case "MOD"
sContentType = "audio/mod"
Case "MOOV", "MOV", "QT"
sContentType = "video/quicktime"
Case "MOVIE", "MV"
sContentType = "video/x-sgi-movie"
Case "MPC", "MPT", "MPV", "MPX"
sContentType = "application/x-project"
Case "MPP"
sContentType = "application/vnd.ms-projec
Case "MRC"
sContentType = "application/marc"
Case "MS"
sContentType = "application/x-troff-ms"
Case "MZZ"
sContentType = "application/x-vnd.audioex
Case "NAP", "NAPLPS image/naplps"
Case "NC"
sContentType = "application/x-netcdf"
Case "NCM"
sContentType = "application/vnd.nokia.con
Case "NIF", "NIFF"
sContentType = "image/x-niff"
Case "NIX"
sContentType = "application/x-mix-transfe
Case "NSC"
sContentType = "application/x-conference"
Case "NVD"
sContentType = "application/x-navidoc"
Case "ODA"
sContentType = "application/oda"
Case "OMC"
sContentType = "application/x-omc"
Case "OMCD"
sContentType = "application/x-omcdatamake
Case "OMCR"
sContentType = "application/x-omcregerato
Case "P"
sContentType = "text/x-pascal"
Case "P10"
sContentType = "application/pkcs10"
Case "P12"
sContentType = "application/pkcs-12"
Case "P7A"
sContentType = "application/x-pkcs7-signa
Case "P7C", "P7M"
sContentType = "application/pkcs7-mime"
Case "P7R"
sContentType = "application/x-pkcs7-certr
Case "P7S"
sContentType = "application/pkcs7-signatu
Case "PART", "PRT"
sContentType = "application/pro_eng"
Case "PAS"
sContentType = "text/pascal"
Case "PBM"
sContentType = "image/x-portable-bitmap"
Case "PCL"
sContentType = "application/vnd.hp-pcl"
Case "PCT"
sContentType = "image/x-pict"
Case "PCX"
sContentType = "image/x-pcx"
Case "PDB", "XYZ"
sContentType = "chemical/x-pdb"
Case "PDF"
sContentType = "application/pdf"
Case "PGM"
sContentType = "image/x-portable-greymap"
Case "PIC", "PICT"
sContentType = "image/pict"
Case "PKG"
sContentType = "application/x-newton-comp
Case "PKO"
sContentType = "application/vnd.ms-pki.pk
Case "PLX"
sContentType = "application/x-pixclscript
Case "PM"
sContentType = "text/x-script.perl-module
Case "PM4", "PM5"
sContentType = "application/x-pagemaker"
Case "PNG", "X-PNG"
sContentType = "image/png"
Case "PNM"
sContentType = "image/x-portable-anymap"
Case "POT", "PPA", "PPS", "PPT", "PPZ", "PWZ"
sContentType = "application/powerpoint"
Case "POV"
sContentType = "model/x-pov"
Case "PPM"
sContentType = "image/x-portable-pixmap"
Case "PRE"
sContentType = "application/x-freelance"
Case "PVU"
sContentType = "paleovu/x-pv"
Case "PY"
sContentType = "text/x-script.phyton"
Case "PYC"
sContentType = "applicaiton/x-bytecode.py
Case "QCP"
sContentType = "audio/vnd.qcelp"
Case "QIF", "QTI", "QTIF"
sContentType = "image/x-quicktime"
Case "QTC"
sContentType = "video/x-qtc"
Case "RA"
sContentType = "audio/x-realaudio"
Case "RA", "RAM", "RM", "RMM", "RMP"
sContentType = "audio/x-pn-realaudio"
Case "RAS", "RAST"
sContentType = "image/cmu-raster"
Case "REXX"
sContentType = "text/x-script.rexx"
Case "RF"
sContentType = "image/vnd.rn-realflash"
Case "RGB"
sContentType = "image/x-rgb"
Case "RMI"
sContentType = "audio/mid"
Case "RNG"
sContentType = "application/ringing-tones
Case "RNX"
sContentType = "application/vnd.rn-realpl
Case "ROFF"
sContentType = "application/x-troff"
Case "RP"
sContentType = "image/vnd.rn-realpix"
Case "RPM"
sContentType = "audio/x-pn-realaudio-plug
Case "RT", "RTF", "RTX"
sContentType = "text/richtext"
Case "RV"
sContentType = "video/vnd.rn-realvideo"
Case "S3M"
sContentType = "audio/s3m"
Case "SBK"
sContentType = "application/x-tbook"
Case "SCM"
sContentType = "application/x-lotusscreen
Case "SDP"
sContentType = "application/sdp"
Case "SDR"
sContentType = "application/sounder"
Case "SEA"
sContentType = "application/sea"
Case "SET"
sContentType = "application/set"
Case "SGM", "SGML"
sContentType = "text/sgml"
Case "SH"
sContentType = "application/x-sh"
Case "SID"
sContentType = "audio/x-psid"
Case "SIT"
sContentType = "application/x-sit"
Case "SKD", "SKM", "SKP", "SKT"
sContentType = "application/x-koan"
Case "SL"
sContentType = "application/x-seelogo"
Case "SMI", "SMIL"
sContentType = "application/smil"
Case "SND"
sContentType = "audio/basic"
Case "SOL"
sContentType = "application/solids"
Case "SPC"
sContentType = "application/x-pkcs7-certi
Case "SPL"
sContentType = "application/futuresplash"
Case "SPR", "SPRITE application/x-sprite"
Case "SRC", "WSRC"
sContentType = "application/x-wais-source
Case "SSI"
sContentType = "text/x-server-parsed-html
Case "SSM"
sContentType = "application/streamingmedi
Case "SST"
sContentType = "application/vnd.ms-pki.ce
Case "STEP", "STP"
sContentType = "application/step"
Case "STL"
sContentType = "application/sla"
Case "SV4CPIO application/x-sv4cpio"
Case "SV4CRC application/x-sv4crc"
Case "SVR"
sContentType = "application/x-world"
Case "SWF"
sContentType = "application/x-shockwave-f
Case "T"
sContentType = "application/x-troff"
Case "TALK"
sContentType = "text/x-speech"
Case "TAR"
sContentType = "application/x-tar"
Case "TBK"
sContentType = "application/toolbook"
Case "TCL"
sContentType = "application/x-tcl"
Case "TCSH"
sContentType = "text/x-script.tcsh"
Case "TEX"
sContentType = "application/x-tex"
Case "TEXI", "TEXINFO application/x-texinfo"
Case "TGZ"
sContentType = "application/gnutar"
Case "TIF", "TIFF"
sContentType = "image/tiff"
Case "TR"
sContentType = "application/x-troff"
Case "TSI"
sContentType = "audio/tsp-audio"
Case "TSP"
sContentType = "audio/tsplayer"
Case "TSV"
sContentType = "text/tab-separated-values
Case "UIL"
sContentType = "text/x-uil"
Case "UNI", "UNIS", "URI", "URIS"
sContentType = "text/uri-list"
Case "UNV"
sContentType = "application/i-deas"
Case "USTAR"
sContentType = "application/x-ustar"
Case "UU", "UUE"
sContentType = "text/x-uuencode"
Case "VCD"
sContentType = "application/x-cdlink"
Case "VCS"
sContentType = "text/x-vcalendar"
Case "VDA"
sContentType = "application/vda"
Case "VDO"
sContentType = "video/vdo"
Case "VEW"
sContentType = "application/groupwise"
Case "VIV", "VIVO"
sContentType = "video/vivo"
Case "VMD"
sContentType = "application/vocaltec-medi
Case "VMF"
sContentType = "application/vocaltec-medi
Case "VOC"
sContentType = "audio/voc"
Case "VOS"
sContentType = "video/vosaic"
Case "VOX"
sContentType = "audio/voxware"
Case "VQE", "VQL"
sContentType = "audio/x-twinvq-plugin"
Case "VQF"
sContentType = "audio/x-twinvq"
Case "VRML", "WRL", "WRZ"
sContentType = "model/vrml"
Case "VRT"
sContentType = "x-world/x-vrt"
Case "VSD", "VST", "VSW"
sContentType = "application/x-visio"
Case "W60"
sContentType = "application/wordperfect6.
Case "W61"
sContentType = "application/wordperfect6.
Case "WAV"
sContentType = "audio/wav"
Case "WAX"
sContentType = "audio/x-ms-wax "
Case "WB1"
sContentType = "application/x-qpro"
Case "WBMP"
sContentType = "image/vnd.wap.wbmp"
Case "WEB"
sContentType = "application/vnd.xara"
Case "WK1"
sContentType = "application/x-123"
Case "WM"
sContentType = "video/x-ms-wm "
Case "WMA"
sContentType = "audio/x-ms-wma "
Case "WMD"
sContentType = "application/x-ms-wmd "
Case "WMF"
sContentType = "windows/metafile"
Case "WML"
sContentType = "text/vnd.wap.wml"
Case "WMLC"
sContentType = "application/vnd.wap.wmlc"
Case "WMLS"
sContentType = "text/vnd.wap.wmlscript"
Case "WMLSC"
sContentType = "application/vnd.wap.wmlsc
Case "WMV"
sContentType = "video/x-ms-wmv "
Case "WMX"
sContentType = "video/x-ms-wmx "
Case "WMZ"
sContentType = "application/x-ms-wmz "
Case "WP", "WP5", "WP6", "WPD"
sContentType = "application/wordperfect"
Case "WQ1"
sContentType = "application/x-lotus"
Case "WRI"
sContentType = "application/mswrite"
Case "WSC"
sContentType = "text/scriplet"
Case "WTK"
sContentType = "application/x-wintalk"
Case "WVX"
sContentType = "video/x-ms-wvx "
Case "XBM", "XPM"
sContentType = "image/xpm"
Case "XDR"
sContentType = "video/x-amt-demorun"
Case "XGZ"
sContentType = "xgl/drawing"
Case "XIF"
sContentType = "image/vnd.xiff"
Case "XL", "XLA", "XLB", "XLC", "XLD", "XLK", "XLL", "XLM", "XLS", "XLT", "XLV", "XLW"
sContentType = "application/excel"
Case "XM"
sContentType = "audio/xm"
Case "XML"
sContentType = "application/xml"
Case "XMZ"
sContentType = "xgl/movie"
Case "XPIX"
sContentType = "application/x-vnd.ls-xpix
Case "XSR"
sContentType = "video/x-amt-showrun"
Case "XWD"
sContentType = "image/x-xwd"
Case "Z"
sContentType = "application/x-compressed"
Case "ZIP"
sContentType = "application/zip"
Case "ZSH"
sContentType = "text/x-script.zsh"
Case Else
sContentType = "application/octet-stream"
End Select
If Left(sContentType, InStr(1, sContentType, "/", vbTextCompare) - 1) Then
lStreamType = adTypeText
Else
lStreamType = adTypeBinary
End If
Response.ContentType = sContentType
' open a stream
Set objStream = Server.CreateObject("ADODB
objStream.Open
' set type
objStream.Type = lStreamType
<snip>
(assuption: variables DIMed, adType-constants defined)
That'd... pretty much do it. Maybe encapsulise it in a function so that your code is neater.
The windows filesystem doesn't seem to keep a real mime-type, just extensions. - its very 'bolted on' the side. (Unlike the old mac and beos fs's)
The windows filesystem doesn't seem to keep a real mime-type, just extensions. - its very 'bolted on' the side. (Unlike the old mac and beos fs's)
and i should have done the right in the first comment better...
ASKER
Too bad, but thanks for you effort
ASKER