mime.go 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. package oss
  2. import (
  3. "mime"
  4. "path"
  5. "strings"
  6. )
  7. var extToMimeType = map[string]string{
  8. ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
  9. ".xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
  10. ".potx": "application/vnd.openxmlformats-officedocument.presentationml.template",
  11. ".ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
  12. ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
  13. ".sldx": "application/vnd.openxmlformats-officedocument.presentationml.slide",
  14. ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  15. ".dotx": "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
  16. ".xlam": "application/vnd.ms-excel.addin.macroEnabled.12",
  17. ".xlsb": "application/vnd.ms-excel.sheet.binary.macroEnabled.12",
  18. ".apk": "application/vnd.android.package-archive",
  19. ".hqx": "application/mac-binhex40",
  20. ".cpt": "application/mac-compactpro",
  21. ".doc": "application/msword",
  22. ".ogg": "application/ogg",
  23. ".pdf": "application/pdf",
  24. ".rtf": "text/rtf",
  25. ".mif": "application/vnd.mif",
  26. ".xls": "application/vnd.ms-excel",
  27. ".ppt": "application/vnd.ms-powerpoint",
  28. ".odc": "application/vnd.oasis.opendocument.chart",
  29. ".odb": "application/vnd.oasis.opendocument.database",
  30. ".odf": "application/vnd.oasis.opendocument.formula",
  31. ".odg": "application/vnd.oasis.opendocument.graphics",
  32. ".otg": "application/vnd.oasis.opendocument.graphics-template",
  33. ".odi": "application/vnd.oasis.opendocument.image",
  34. ".odp": "application/vnd.oasis.opendocument.presentation",
  35. ".otp": "application/vnd.oasis.opendocument.presentation-template",
  36. ".ods": "application/vnd.oasis.opendocument.spreadsheet",
  37. ".ots": "application/vnd.oasis.opendocument.spreadsheet-template",
  38. ".odt": "application/vnd.oasis.opendocument.text",
  39. ".odm": "application/vnd.oasis.opendocument.text-master",
  40. ".ott": "application/vnd.oasis.opendocument.text-template",
  41. ".oth": "application/vnd.oasis.opendocument.text-web",
  42. ".sxw": "application/vnd.sun.xml.writer",
  43. ".stw": "application/vnd.sun.xml.writer.template",
  44. ".sxc": "application/vnd.sun.xml.calc",
  45. ".stc": "application/vnd.sun.xml.calc.template",
  46. ".sxd": "application/vnd.sun.xml.draw",
  47. ".std": "application/vnd.sun.xml.draw.template",
  48. ".sxi": "application/vnd.sun.xml.impress",
  49. ".sti": "application/vnd.sun.xml.impress.template",
  50. ".sxg": "application/vnd.sun.xml.writer.global",
  51. ".sxm": "application/vnd.sun.xml.math",
  52. ".sis": "application/vnd.symbian.install",
  53. ".wbxml": "application/vnd.wap.wbxml",
  54. ".wmlc": "application/vnd.wap.wmlc",
  55. ".wmlsc": "application/vnd.wap.wmlscriptc",
  56. ".bcpio": "application/x-bcpio",
  57. ".torrent": "application/x-bittorrent",
  58. ".bz2": "application/x-bzip2",
  59. ".vcd": "application/x-cdlink",
  60. ".pgn": "application/x-chess-pgn",
  61. ".cpio": "application/x-cpio",
  62. ".csh": "application/x-csh",
  63. ".dvi": "application/x-dvi",
  64. ".spl": "application/x-futuresplash",
  65. ".gtar": "application/x-gtar",
  66. ".hdf": "application/x-hdf",
  67. ".jar": "application/x-java-archive",
  68. ".jnlp": "application/x-java-jnlp-file",
  69. ".js": "application/x-javascript",
  70. ".ksp": "application/x-kspread",
  71. ".chrt": "application/x-kchart",
  72. ".kil": "application/x-killustrator",
  73. ".latex": "application/x-latex",
  74. ".rpm": "application/x-rpm",
  75. ".sh": "application/x-sh",
  76. ".shar": "application/x-shar",
  77. ".swf": "application/x-shockwave-flash",
  78. ".sit": "application/x-stuffit",
  79. ".sv4cpio": "application/x-sv4cpio",
  80. ".sv4crc": "application/x-sv4crc",
  81. ".tar": "application/x-tar",
  82. ".tcl": "application/x-tcl",
  83. ".tex": "application/x-tex",
  84. ".man": "application/x-troff-man",
  85. ".me": "application/x-troff-me",
  86. ".ms": "application/x-troff-ms",
  87. ".ustar": "application/x-ustar",
  88. ".src": "application/x-wais-source",
  89. ".zip": "application/zip",
  90. ".m3u": "audio/x-mpegurl",
  91. ".ra": "audio/x-pn-realaudio",
  92. ".wav": "audio/x-wav",
  93. ".wma": "audio/x-ms-wma",
  94. ".wax": "audio/x-ms-wax",
  95. ".pdb": "chemical/x-pdb",
  96. ".xyz": "chemical/x-xyz",
  97. ".bmp": "image/bmp",
  98. ".gif": "image/gif",
  99. ".ief": "image/ief",
  100. ".png": "image/png",
  101. ".wbmp": "image/vnd.wap.wbmp",
  102. ".ras": "image/x-cmu-raster",
  103. ".pnm": "image/x-portable-anymap",
  104. ".pbm": "image/x-portable-bitmap",
  105. ".pgm": "image/x-portable-graymap",
  106. ".ppm": "image/x-portable-pixmap",
  107. ".rgb": "image/x-rgb",
  108. ".xbm": "image/x-xbitmap",
  109. ".xpm": "image/x-xpixmap",
  110. ".xwd": "image/x-xwindowdump",
  111. ".css": "text/css",
  112. ".rtx": "text/richtext",
  113. ".tsv": "text/tab-separated-values",
  114. ".jad": "text/vnd.sun.j2me.app-descriptor",
  115. ".wml": "text/vnd.wap.wml",
  116. ".wmls": "text/vnd.wap.wmlscript",
  117. ".etx": "text/x-setext",
  118. ".mxu": "video/vnd.mpegurl",
  119. ".flv": "video/x-flv",
  120. ".wm": "video/x-ms-wm",
  121. ".wmv": "video/x-ms-wmv",
  122. ".wmx": "video/x-ms-wmx",
  123. ".wvx": "video/x-ms-wvx",
  124. ".avi": "video/x-msvideo",
  125. ".movie": "video/x-sgi-movie",
  126. ".ice": "x-conference/x-cooltalk",
  127. ".3gp": "video/3gpp",
  128. ".ai": "application/postscript",
  129. ".aif": "audio/x-aiff",
  130. ".aifc": "audio/x-aiff",
  131. ".aiff": "audio/x-aiff",
  132. ".asc": "text/plain",
  133. ".atom": "application/atom+xml",
  134. ".au": "audio/basic",
  135. ".bin": "application/octet-stream",
  136. ".cdf": "application/x-netcdf",
  137. ".cgm": "image/cgm",
  138. ".class": "application/octet-stream",
  139. ".dcr": "application/x-director",
  140. ".dif": "video/x-dv",
  141. ".dir": "application/x-director",
  142. ".djv": "image/vnd.djvu",
  143. ".djvu": "image/vnd.djvu",
  144. ".dll": "application/octet-stream",
  145. ".dmg": "application/octet-stream",
  146. ".dms": "application/octet-stream",
  147. ".dtd": "application/xml-dtd",
  148. ".dv": "video/x-dv",
  149. ".dxr": "application/x-director",
  150. ".eps": "application/postscript",
  151. ".exe": "application/octet-stream",
  152. ".ez": "application/andrew-inset",
  153. ".gram": "application/srgs",
  154. ".grxml": "application/srgs+xml",
  155. ".gz": "application/x-gzip",
  156. ".htm": "text/html",
  157. ".html": "text/html",
  158. ".ico": "image/x-icon",
  159. ".ics": "text/calendar",
  160. ".ifb": "text/calendar",
  161. ".iges": "model/iges",
  162. ".igs": "model/iges",
  163. ".jp2": "image/jp2",
  164. ".jpe": "image/jpeg",
  165. ".jpeg": "image/jpeg",
  166. ".jpg": "image/jpeg",
  167. ".kar": "audio/midi",
  168. ".lha": "application/octet-stream",
  169. ".lzh": "application/octet-stream",
  170. ".m4a": "audio/mp4a-latm",
  171. ".m4p": "audio/mp4a-latm",
  172. ".m4u": "video/vnd.mpegurl",
  173. ".m4v": "video/x-m4v",
  174. ".mac": "image/x-macpaint",
  175. ".mathml": "application/mathml+xml",
  176. ".mesh": "model/mesh",
  177. ".mid": "audio/midi",
  178. ".midi": "audio/midi",
  179. ".mov": "video/quicktime",
  180. ".mp2": "audio/mpeg",
  181. ".mp3": "audio/mpeg",
  182. ".mp4": "video/mp4",
  183. ".mpe": "video/mpeg",
  184. ".mpeg": "video/mpeg",
  185. ".mpg": "video/mpeg",
  186. ".mpga": "audio/mpeg",
  187. ".msh": "model/mesh",
  188. ".nc": "application/x-netcdf",
  189. ".oda": "application/oda",
  190. ".ogv": "video/ogv",
  191. ".pct": "image/pict",
  192. ".pic": "image/pict",
  193. ".pict": "image/pict",
  194. ".pnt": "image/x-macpaint",
  195. ".pntg": "image/x-macpaint",
  196. ".ps": "application/postscript",
  197. ".qt": "video/quicktime",
  198. ".qti": "image/x-quicktime",
  199. ".qtif": "image/x-quicktime",
  200. ".ram": "audio/x-pn-realaudio",
  201. ".rdf": "application/rdf+xml",
  202. ".rm": "application/vnd.rn-realmedia",
  203. ".roff": "application/x-troff",
  204. ".sgm": "text/sgml",
  205. ".sgml": "text/sgml",
  206. ".silo": "model/mesh",
  207. ".skd": "application/x-koan",
  208. ".skm": "application/x-koan",
  209. ".skp": "application/x-koan",
  210. ".skt": "application/x-koan",
  211. ".smi": "application/smil",
  212. ".smil": "application/smil",
  213. ".snd": "audio/basic",
  214. ".so": "application/octet-stream",
  215. ".svg": "image/svg+xml",
  216. ".t": "application/x-troff",
  217. ".texi": "application/x-texinfo",
  218. ".texinfo": "application/x-texinfo",
  219. ".tif": "image/tiff",
  220. ".tiff": "image/tiff",
  221. ".tr": "application/x-troff",
  222. ".txt": "text/plain",
  223. ".vrml": "model/vrml",
  224. ".vxml": "application/voicexml+xml",
  225. ".webm": "video/webm",
  226. ".wrl": "model/vrml",
  227. ".xht": "application/xhtml+xml",
  228. ".xhtml": "application/xhtml+xml",
  229. ".xml": "application/xml",
  230. ".xsl": "application/xml",
  231. ".xslt": "application/xslt+xml",
  232. ".xul": "application/vnd.mozilla.xul+xml",
  233. ".webp": "image/webp",
  234. ".323": "text/h323",
  235. ".aab": "application/x-authoware-bin",
  236. ".aam": "application/x-authoware-map",
  237. ".aas": "application/x-authoware-seg",
  238. ".acx": "application/internet-property-stream",
  239. ".als": "audio/X-Alpha5",
  240. ".amc": "application/x-mpeg",
  241. ".ani": "application/octet-stream",
  242. ".asd": "application/astound",
  243. ".asf": "video/x-ms-asf",
  244. ".asn": "application/astound",
  245. ".asp": "application/x-asap",
  246. ".asr": "video/x-ms-asf",
  247. ".asx": "video/x-ms-asf",
  248. ".avb": "application/octet-stream",
  249. ".awb": "audio/amr-wb",
  250. ".axs": "application/olescript",
  251. ".bas": "text/plain",
  252. ".bin ": "application/octet-stream",
  253. ".bld": "application/bld",
  254. ".bld2": "application/bld2",
  255. ".bpk": "application/octet-stream",
  256. ".c": "text/plain",
  257. ".cal": "image/x-cals",
  258. ".cat": "application/vnd.ms-pkiseccat",
  259. ".ccn": "application/x-cnc",
  260. ".cco": "application/x-cocoa",
  261. ".cer": "application/x-x509-ca-cert",
  262. ".cgi": "magnus-internal/cgi",
  263. ".chat": "application/x-chat",
  264. ".clp": "application/x-msclip",
  265. ".cmx": "image/x-cmx",
  266. ".co": "application/x-cult3d-object",
  267. ".cod": "image/cis-cod",
  268. ".conf": "text/plain",
  269. ".cpp": "text/plain",
  270. ".crd": "application/x-mscardfile",
  271. ".crl": "application/pkix-crl",
  272. ".crt": "application/x-x509-ca-cert",
  273. ".csm": "chemical/x-csml",
  274. ".csml": "chemical/x-csml",
  275. ".cur": "application/octet-stream",
  276. ".dcm": "x-lml/x-evm",
  277. ".dcx": "image/x-dcx",
  278. ".der": "application/x-x509-ca-cert",
  279. ".dhtml": "text/html",
  280. ".dot": "application/msword",
  281. ".dwf": "drawing/x-dwf",
  282. ".dwg": "application/x-autocad",
  283. ".dxf": "application/x-autocad",
  284. ".ebk": "application/x-expandedbook",
  285. ".emb": "chemical/x-embl-dl-nucleotide",
  286. ".embl": "chemical/x-embl-dl-nucleotide",
  287. ".epub": "application/epub+zip",
  288. ".eri": "image/x-eri",
  289. ".es": "audio/echospeech",
  290. ".esl": "audio/echospeech",
  291. ".etc": "application/x-earthtime",
  292. ".evm": "x-lml/x-evm",
  293. ".evy": "application/envoy",
  294. ".fh4": "image/x-freehand",
  295. ".fh5": "image/x-freehand",
  296. ".fhc": "image/x-freehand",
  297. ".fif": "application/fractals",
  298. ".flr": "x-world/x-vrml",
  299. ".fm": "application/x-maker",
  300. ".fpx": "image/x-fpx",
  301. ".fvi": "video/isivideo",
  302. ".gau": "chemical/x-gaussian-input",
  303. ".gca": "application/x-gca-compressed",
  304. ".gdb": "x-lml/x-gdb",
  305. ".gps": "application/x-gps",
  306. ".h": "text/plain",
  307. ".hdm": "text/x-hdml",
  308. ".hdml": "text/x-hdml",
  309. ".hlp": "application/winhlp",
  310. ".hta": "application/hta",
  311. ".htc": "text/x-component",
  312. ".hts": "text/html",
  313. ".htt": "text/webviewhtml",
  314. ".ifm": "image/gif",
  315. ".ifs": "image/ifs",
  316. ".iii": "application/x-iphone",
  317. ".imy": "audio/melody",
  318. ".ins": "application/x-internet-signup",
  319. ".ips": "application/x-ipscript",
  320. ".ipx": "application/x-ipix",
  321. ".isp": "application/x-internet-signup",
  322. ".it": "audio/x-mod",
  323. ".itz": "audio/x-mod",
  324. ".ivr": "i-world/i-vrml",
  325. ".j2k": "image/j2k",
  326. ".jam": "application/x-jam",
  327. ".java": "text/plain",
  328. ".jfif": "image/pipeg",
  329. ".jpz": "image/jpeg",
  330. ".jwc": "application/jwc",
  331. ".kjx": "application/x-kjx",
  332. ".lak": "x-lml/x-lak",
  333. ".lcc": "application/fastman",
  334. ".lcl": "application/x-digitalloca",
  335. ".lcr": "application/x-digitalloca",
  336. ".lgh": "application/lgh",
  337. ".lml": "x-lml/x-lml",
  338. ".lmlpack": "x-lml/x-lmlpack",
  339. ".log": "text/plain",
  340. ".lsf": "video/x-la-asf",
  341. ".lsx": "video/x-la-asf",
  342. ".m13": "application/x-msmediaview",
  343. ".m14": "application/x-msmediaview",
  344. ".m15": "audio/x-mod",
  345. ".m3url": "audio/x-mpegurl",
  346. ".m4b": "audio/mp4a-latm",
  347. ".ma1": "audio/ma1",
  348. ".ma2": "audio/ma2",
  349. ".ma3": "audio/ma3",
  350. ".ma5": "audio/ma5",
  351. ".map": "magnus-internal/imagemap",
  352. ".mbd": "application/mbedlet",
  353. ".mct": "application/x-mascot",
  354. ".mdb": "application/x-msaccess",
  355. ".mdz": "audio/x-mod",
  356. ".mel": "text/x-vmel",
  357. ".mht": "message/rfc822",
  358. ".mhtml": "message/rfc822",
  359. ".mi": "application/x-mif",
  360. ".mil": "image/x-cals",
  361. ".mio": "audio/x-mio",
  362. ".mmf": "application/x-skt-lbs",
  363. ".mng": "video/x-mng",
  364. ".mny": "application/x-msmoney",
  365. ".moc": "application/x-mocha",
  366. ".mocha": "application/x-mocha",
  367. ".mod": "audio/x-mod",
  368. ".mof": "application/x-yumekara",
  369. ".mol": "chemical/x-mdl-molfile",
  370. ".mop": "chemical/x-mopac-input",
  371. ".mpa": "video/mpeg",
  372. ".mpc": "application/vnd.mpohun.certificate",
  373. ".mpg4": "video/mp4",
  374. ".mpn": "application/vnd.mophun.application",
  375. ".mpp": "application/vnd.ms-project",
  376. ".mps": "application/x-mapserver",
  377. ".mpv2": "video/mpeg",
  378. ".mrl": "text/x-mrml",
  379. ".mrm": "application/x-mrm",
  380. ".msg": "application/vnd.ms-outlook",
  381. ".mts": "application/metastream",
  382. ".mtx": "application/metastream",
  383. ".mtz": "application/metastream",
  384. ".mvb": "application/x-msmediaview",
  385. ".mzv": "application/metastream",
  386. ".nar": "application/zip",
  387. ".nbmp": "image/nbmp",
  388. ".ndb": "x-lml/x-ndb",
  389. ".ndwn": "application/ndwn",
  390. ".nif": "application/x-nif",
  391. ".nmz": "application/x-scream",
  392. ".nokia-op-logo": "image/vnd.nok-oplogo-color",
  393. ".npx": "application/x-netfpx",
  394. ".nsnd": "audio/nsnd",
  395. ".nva": "application/x-neva1",
  396. ".nws": "message/rfc822",
  397. ".oom": "application/x-AtlasMate-Plugin",
  398. ".p10": "application/pkcs10",
  399. ".p12": "application/x-pkcs12",
  400. ".p7b": "application/x-pkcs7-certificates",
  401. ".p7c": "application/x-pkcs7-mime",
  402. ".p7m": "application/x-pkcs7-mime",
  403. ".p7r": "application/x-pkcs7-certreqresp",
  404. ".p7s": "application/x-pkcs7-signature",
  405. ".pac": "audio/x-pac",
  406. ".pae": "audio/x-epac",
  407. ".pan": "application/x-pan",
  408. ".pcx": "image/x-pcx",
  409. ".pda": "image/x-pda",
  410. ".pfr": "application/font-tdpfr",
  411. ".pfx": "application/x-pkcs12",
  412. ".pko": "application/ynd.ms-pkipko",
  413. ".pm": "application/x-perl",
  414. ".pma": "application/x-perfmon",
  415. ".pmc": "application/x-perfmon",
  416. ".pmd": "application/x-pmd",
  417. ".pml": "application/x-perfmon",
  418. ".pmr": "application/x-perfmon",
  419. ".pmw": "application/x-perfmon",
  420. ".pnz": "image/png",
  421. ".pot,": "application/vnd.ms-powerpoint",
  422. ".pps": "application/vnd.ms-powerpoint",
  423. ".pqf": "application/x-cprplayer",
  424. ".pqi": "application/cprplayer",
  425. ".prc": "application/x-prc",
  426. ".prf": "application/pics-rules",
  427. ".prop": "text/plain",
  428. ".proxy": "application/x-ns-proxy-autoconfig",
  429. ".ptlk": "application/listenup",
  430. ".pub": "application/x-mspublisher",
  431. ".pvx": "video/x-pv-pvx",
  432. ".qcp": "audio/vnd.qcelp",
  433. ".r3t": "text/vnd.rn-realtext3d",
  434. ".rar": "application/octet-stream",
  435. ".rc": "text/plain",
  436. ".rf": "image/vnd.rn-realflash",
  437. ".rlf": "application/x-richlink",
  438. ".rmf": "audio/x-rmf",
  439. ".rmi": "audio/mid",
  440. ".rmm": "audio/x-pn-realaudio",
  441. ".rmvb": "audio/x-pn-realaudio",
  442. ".rnx": "application/vnd.rn-realplayer",
  443. ".rp": "image/vnd.rn-realpix",
  444. ".rt": "text/vnd.rn-realtext",
  445. ".rte": "x-lml/x-gps",
  446. ".rtg": "application/metastream",
  447. ".rv": "video/vnd.rn-realvideo",
  448. ".rwc": "application/x-rogerwilco",
  449. ".s3m": "audio/x-mod",
  450. ".s3z": "audio/x-mod",
  451. ".sca": "application/x-supercard",
  452. ".scd": "application/x-msschedule",
  453. ".sct": "text/scriptlet",
  454. ".sdf": "application/e-score",
  455. ".sea": "application/x-stuffit",
  456. ".setpay": "application/set-payment-initiation",
  457. ".setreg": "application/set-registration-initiation",
  458. ".shtml": "text/html",
  459. ".shtm": "text/html",
  460. ".shw": "application/presentations",
  461. ".si6": "image/si6",
  462. ".si7": "image/vnd.stiwap.sis",
  463. ".si9": "image/vnd.lgtwap.sis",
  464. ".slc": "application/x-salsa",
  465. ".smd": "audio/x-smd",
  466. ".smp": "application/studiom",
  467. ".smz": "audio/x-smd",
  468. ".spc": "application/x-pkcs7-certificates",
  469. ".spr": "application/x-sprite",
  470. ".sprite": "application/x-sprite",
  471. ".sdp": "application/sdp",
  472. ".spt": "application/x-spt",
  473. ".sst": "application/vnd.ms-pkicertstore",
  474. ".stk": "application/hyperstudio",
  475. ".stl": "application/vnd.ms-pkistl",
  476. ".stm": "text/html",
  477. ".svf": "image/vnd",
  478. ".svh": "image/svh",
  479. ".svr": "x-world/x-svr",
  480. ".swfl": "application/x-shockwave-flash",
  481. ".tad": "application/octet-stream",
  482. ".talk": "text/x-speech",
  483. ".taz": "application/x-tar",
  484. ".tbp": "application/x-timbuktu",
  485. ".tbt": "application/x-timbuktu",
  486. ".tgz": "application/x-compressed",
  487. ".thm": "application/vnd.eri.thm",
  488. ".tki": "application/x-tkined",
  489. ".tkined": "application/x-tkined",
  490. ".toc": "application/toc",
  491. ".toy": "image/toy",
  492. ".trk": "x-lml/x-gps",
  493. ".trm": "application/x-msterminal",
  494. ".tsi": "audio/tsplayer",
  495. ".tsp": "application/dsptype",
  496. ".ttf": "application/octet-stream",
  497. ".ttz": "application/t-time",
  498. ".uls": "text/iuls",
  499. ".ult": "audio/x-mod",
  500. ".uu": "application/x-uuencode",
  501. ".uue": "application/x-uuencode",
  502. ".vcf": "text/x-vcard",
  503. ".vdo": "video/vdo",
  504. ".vib": "audio/vib",
  505. ".viv": "video/vivo",
  506. ".vivo": "video/vivo",
  507. ".vmd": "application/vocaltec-media-desc",
  508. ".vmf": "application/vocaltec-media-file",
  509. ".vmi": "application/x-dreamcast-vms-info",
  510. ".vms": "application/x-dreamcast-vms",
  511. ".vox": "audio/voxware",
  512. ".vqe": "audio/x-twinvq-plugin",
  513. ".vqf": "audio/x-twinvq",
  514. ".vql": "audio/x-twinvq",
  515. ".vre": "x-world/x-vream",
  516. ".vrt": "x-world/x-vrt",
  517. ".vrw": "x-world/x-vream",
  518. ".vts": "workbook/formulaone",
  519. ".wcm": "application/vnd.ms-works",
  520. ".wdb": "application/vnd.ms-works",
  521. ".web": "application/vnd.xara",
  522. ".wi": "image/wavelet",
  523. ".wis": "application/x-InstallShield",
  524. ".wks": "application/vnd.ms-works",
  525. ".wmd": "application/x-ms-wmd",
  526. ".wmf": "application/x-msmetafile",
  527. ".wmlscript": "text/vnd.wap.wmlscript",
  528. ".wmz": "application/x-ms-wmz",
  529. ".wpng": "image/x-up-wpng",
  530. ".wps": "application/vnd.ms-works",
  531. ".wpt": "x-lml/x-gps",
  532. ".wri": "application/x-mswrite",
  533. ".wrz": "x-world/x-vrml",
  534. ".ws": "text/vnd.wap.wmlscript",
  535. ".wsc": "application/vnd.wap.wmlscriptc",
  536. ".wv": "video/wavelet",
  537. ".wxl": "application/x-wxl",
  538. ".x-gzip": "application/x-gzip",
  539. ".xaf": "x-world/x-vrml",
  540. ".xar": "application/vnd.xara",
  541. ".xdm": "application/x-xdma",
  542. ".xdma": "application/x-xdma",
  543. ".xdw": "application/vnd.fujixerox.docuworks",
  544. ".xhtm": "application/xhtml+xml",
  545. ".xla": "application/vnd.ms-excel",
  546. ".xlc": "application/vnd.ms-excel",
  547. ".xll": "application/x-excel",
  548. ".xlm": "application/vnd.ms-excel",
  549. ".xlt": "application/vnd.ms-excel",
  550. ".xlw": "application/vnd.ms-excel",
  551. ".xm": "audio/x-mod",
  552. ".xmz": "audio/x-mod",
  553. ".xof": "x-world/x-vrml",
  554. ".xpi": "application/x-xpinstall",
  555. ".xsit": "text/xml",
  556. ".yz1": "application/x-yz1",
  557. ".z": "application/x-compress",
  558. ".zac": "application/x-zaurus-zac",
  559. ".json": "application/json",
  560. }
  561. // TypeByExtension returns the MIME type associated with the file extension ext.
  562. // gets the file's MIME type for HTTP header Content-Type
  563. func TypeByExtension(filePath string) string {
  564. typ := mime.TypeByExtension(path.Ext(filePath))
  565. if typ == "" {
  566. typ = extToMimeType[strings.ToLower(path.Ext(filePath))]
  567. }
  568. return typ
  569. }