2 Copyright (c) 2008, Adobe Systems Incorporated
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
9 * Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 * Neither the name of Adobe Systems Incorporated nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 public class MimeTypeMap
36 private var types:Array =
37 [["application/andrew-inset","ez"],
38 ["application/atom+xml","atom"],
39 ["application/mac-binhex40","hqx"],
40 ["application/mac-compactpro","cpt"],
41 ["application/mathml+xml","mathml"],
42 ["application/msword","doc"],
43 ["application/octet-stream","bin","dms","lha","lzh","exe","class","so","dll","dmg"],
44 ["application/oda","oda"],
45 ["application/ogg","ogg"],
46 ["application/pdf","pdf"],
47 ["application/postscript","ai","eps","ps"],
48 ["application/rdf+xml","rdf"],
49 ["application/smil","smi","smil"],
50 ["application/srgs","gram"],
51 ["application/srgs+xml","grxml"],
52 ["application/vnd.adobe.apollo-application-installer-package+zip","air"],
53 ["application/vnd.mif","mif"],
54 ["application/vnd.mozilla.xul+xml","xul"],
55 ["application/vnd.ms-excel","xls"],
56 ["application/vnd.ms-powerpoint","ppt"],
57 ["application/vnd.rn-realmedia","rm"],
58 ["application/vnd.wap.wbxml","wbxml"],
59 ["application/vnd.wap.wmlc","wmlc"],
60 ["application/vnd.wap.wmlscriptc","wmlsc"],
61 ["application/voicexml+xml","vxml"],
62 ["application/x-bcpio","bcpio"],
63 ["application/x-cdlink","vcd"],
64 ["application/x-chess-pgn","pgn"],
65 ["application/x-cpio","cpio"],
66 ["application/x-csh","csh"],
67 ["application/x-director","dcr","dir","dxr"],
68 ["application/x-dvi","dvi"],
69 ["application/x-futuresplash","spl"],
70 ["application/x-gtar","gtar"],
71 ["application/x-hdf","hdf"],
72 ["application/x-javascript","js"],
73 ["application/x-koan","skp","skd","skt","skm"],
74 ["application/x-latex","latex"],
75 ["application/x-netcdf","nc","cdf"],
76 ["application/x-sh","sh"],
77 ["application/x-shar","shar"],
78 ["application/x-shockwave-flash","swf"],
79 ["application/x-stuffit","sit"],
80 ["application/x-sv4cpio","sv4cpio"],
81 ["application/x-sv4crc","sv4crc"],
82 ["application/x-tar","tar"],
83 ["application/x-tcl","tcl"],
84 ["application/x-tex","tex"],
85 ["application/x-texinfo","texinfo","texi"],
86 ["application/x-troff","t","tr","roff"],
87 ["application/x-troff-man","man"],
88 ["application/x-troff-me","me"],
89 ["application/x-troff-ms","ms"],
90 ["application/x-ustar","ustar"],
91 ["application/x-wais-source","src"],
92 ["application/xhtml+xml","xhtml","xht"],
93 ["application/xml","xml","xsl"],
94 ["application/xml-dtd","dtd"],
95 ["application/xslt+xml","xslt"],
96 ["application/zip","zip"],
97 ["audio/basic","au","snd"],
98 ["audio/midi","mid","midi","kar"],
99 ["audio/mpeg","mp3","mpga","mp2"],
100 ["audio/x-aiff","aif","aiff","aifc"],
101 ["audio/x-mpegurl","m3u"],
102 ["audio/x-pn-realaudio","ram","ra"],
103 ["audio/x-wav","wav"],
104 ["chemical/x-pdb","pdb"],
105 ["chemical/x-xyz","xyz"],
110 ["image/jpeg","jpg","jpeg","jpe"],
112 ["image/svg+xml","svg"],
113 ["image/tiff","tiff","tif"],
114 ["image/vnd.djvu","djvu","djv"],
115 ["image/vnd.wap.wbmp","wbmp"],
116 ["image/x-cmu-raster","ras"],
117 ["image/x-icon","ico"],
118 ["image/x-portable-anymap","pnm"],
119 ["image/x-portable-bitmap","pbm"],
120 ["image/x-portable-graymap","pgm"],
121 ["image/x-portable-pixmap","ppm"],
122 ["image/x-rgb","rgb"],
123 ["image/x-xbitmap","xbm"],
124 ["image/x-xpixmap","xpm"],
125 ["image/x-xwindowdump","xwd"],
126 ["model/iges","igs","iges"],
127 ["model/mesh","msh","mesh","silo"],
128 ["model/vrml","wrl","vrml"],
129 ["text/calendar","ics","ifb"],
131 ["text/html","html","htm"],
132 ["text/plain","txt","asc"],
133 ["text/richtext","rtx"],
135 ["text/sgml","sgml","sgm"],
136 ["text/tab-separated-values","tsv"],
137 ["text/vnd.wap.wml","wml"],
138 ["text/vnd.wap.wmlscript","wmls"],
139 ["text/x-setext","etx"],
140 ["video/mpeg","mpg","mpeg","mpe"],
141 ["video/quicktime","mov","qt"],
142 ["video/vnd.mpegurl","m4u","mxu"],
143 ["video/x-flv","flv"],
144 ["video/x-msvideo","avi"],
145 ["video/x-sgi-movie","movie"],
146 ["x-conference/x-cooltalk","ice"]];
149 * Returns the mimetype for the given extension.
151 public function getMimeType(extension:String):String
153 extension = extension.toLocaleLowerCase();
154 for each (var a:Array in types)
156 for each (var b:String in a)
168 * Returns the prefered extension for the given mimetype.
170 public function getExtension(mimetype:String):String
172 mimetype = mimetype.toLocaleLowerCase();
173 for each (var a:Array in types)
175 if (a[0] == mimetype)
184 * Adds a mimetype to the map. The order of the extensions matters. The most preferred should come first.
186 public function addMimeType(mimetype:String, extensions:Array):void
188 var newType:Array = [mimetype];
189 for each (var a:String in extensions)