码迷,mamicode.com
首页 > 其他好文 > 详细

IE8下载docx文件发现后缀变为.zip文件

时间:2015-11-26 13:11:05      阅读:498      评论:0      收藏:0      [点我收藏+]

标签:nginx

公司2015-11-09日发现IE8下载docx文件时后缀变为.zip为结尾的文件

后经发现排查后发现传送流无法识别后缀导致,

技术分享


默认当成普通数据流传送了

解决方法:

导致原因:

从IIS或者Tomcat之类的Web服务器通过二进制流下载文件时(比如通过设置Header为Content-disposition:inline),如果被下载的文件是Office2007的dotx,docx,pot等后缀的时候,下载对话框中的图标会变成ZIP的,相应的文件名也会成为zip为扩展后缀的文件。其实出现这样的情况,是由于IE中对下载文件类型的判断,假如找不到相应后缀的MIME的话,会自动根据数据流来判断文件的类型,而微软对Office2007的格式做了和以前完全不同的处理。

以前的Office文档是100%的二进制格式。第三方的工具操作起来非常不方便,而 Office2007从整体上都是基于XML格式的,这里并不是说Office2007文档可以保存成XML格式。而是Office2007默认的文档格式就是XML的(Word的docx、Excel的xlsx等)。也许有人会感到奇怪,用文本编辑器打开docx后,显示的仍然是二进制格式,并不是什么 XML。其实docx并不是普通的XML格式,当然,也不只是一个XML文件,docx本质上是一个zip文件,里面有一系列的xml、目录和其他的文件。如果我们将docx改成zip。就可以用winzip等软件将其解开。


在nginxmime-type文件中加入:

application/vnd.openxmlformats-officedocument.wordprocessingml.document    docx;

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet          xlsx;

 application/vnd.openxmlformats-officedocument.presentationml.presentation  pptx;

重启nginx后测试解决问题。




下面收集了大部分文件的扩展名和相应的MIME对应,有需要的可以在列表中找到并添加

  1. .asx,video/x-ms-asf   

  2. .xml,text/xml   

  3. .tsv,text/tab-separated-values   

  4. .ra,audio/x-pn-realaudio   

  5. .sv4crc,application/x-sv4crc   

  6. .spc,application/x-pkcs7-certificates   

  7. .pmc,application/x-perfmon   

  8. .lit,application/x-ms-reader   

  9. .crd,application/x-mscardfile   

  10. .isp,application/x-internet-signup   

  11. .wmlsc,application/vnd.wap.wmlscriptc   

  12. .vst,application/vnd.visio   

  13. .xlam,application/vnd.ms-excel.addin.macroEnabled.12   

  14. .ttf,application/octet-stream   

  15. .pfm,application/octet-stream   

  16. .csv,application/octet-stream   

  17. .aaf,application/octet-stream   

  18. .one,application/onenote   

  19. .hta,application/hta   

  20. .atom,application/atom+xml   

  21. .323,text/h323   

  22. .mhtml,message/rfc822   

  23. .midi,audio/mid   

  24. .p7r,application/x-pkcs7-certreqresp   

  25. .mny,application/x-msmoney   

  26. .clp,application/x-msclip   

  27. .vsd,application/vnd.visio   

  28. .lpk,application/octet-stream   

  29. .bin,application/octet-stream   

  30. .onetoc,application/onenote   

  31. .x,application/directx   

  32. .wvx,video/x-ms-wvx   

  33. .vcf,text/x-vcard   

  34. .htc,text/x-component   

  35. .htt,text/webviewhtml   

  36. .h,text/plain   

  37. .mht,message/rfc822   

  38. .mid,audio/mid   

  39. .p7b,application/x-pkcs7-certificates   

  40. .gz,application/x-gzip   

  41. .dvi,application/x-dvi   

  42. .cpio,application/x-cpio   

  43. .vdx,application/vnd.ms-visio.viewer   

  44. .sldm,application/vnd.ms-powerpoint.slide.macroEnabled.12   

  45. .xlm,application/vnd.ms-excel   

  46. .fdf,application/vnd.fdf   

  47. .setreg,application/set-registration-initiation   

  48. .eps,application/postscript   

  49. .p7s,application/pkcs7-signature   

  50. .toc,application/octet-stream   

  51. .mdp,application/octet-stream   

  52. .ics,application/octet-stream   

  53. .chm,application/octet-stream   

  54. .asi,application/octet-stream   

  55. .afm,application/octet-stream   

  56. .evy,application/envoy   

  57. .wmp,video/x-ms-wmp   

  58. .qt,video/quicktime   

  59. .mpv2,video/mpeg   

  60. .xslt,text/xml   

  61. .etx,text/x-setext   

  62. .cod,image/cis-cod   

  63. .snd,audio/basic   

  64. .au,audio/basic   

  65. .man,application/x-troff-man   

  66. .qtl,application/x-quicktimeplayer   

  67. .pmw,application/x-perfmon   

  68. .class,application/x-java-applet   

  69. .iii,application/x-iphone   

  70. .csh,application/x-csh   

  71. .z,application/x-compress   

  72. .vtx,application/vnd.visio   

  73. .vsw,application/vnd.visio   

  74. .wps,application/vnd.ms-works   

  75. .potx,application/vnd.openxmlformats-officedocument.presentationml.template   

  76. .ps,application/postscript   

  77. .p7c,application/pkcs7-mime   

  78. .thn,application/octet-stream   

  79. .mso,application/octet-stream   

  80. .dot,application/msword   

  81. .doc,application/msword   

  82. .sgml,text/sgml   

  83. .nws,message/rfc822   

  84. .pbm,image/x-portable-bitmap   

  85. .ief,image/ief   

  86. .wav,audio/wav   

  87. .texi,application/x-texinfo   

  88. .mvb,application/x-msmediaview   

  89. .hdf,application/x-hdf   

  90. .vsx,application/vnd.visio   

  91. .dotm,application/vnd.ms-word.template.macroEnabled.12   

  92. .docm,application/vnd.ms-word.document.macroEnabled.12   

  93. .pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation   

  94. .psm,application/octet-stream   

  95. .java,application/octet-stream   

  96. .eot,application/octet-stream   

  97. .jar,application/java-archive   

  98. .mpeg,video/mpeg   

  99. .xsf,text/xml   

  100. .map,text/plain   

  101. .uls,text/iuls   

  102. .rf,image/vnd.rn-realflash   

  103. .m3u,audio/x-mpegurl   

  104. .wma,audio/x-ms-wma   

  105. .aifc,audio/aiff   

  106. .mdb,application/x-msaccess   

  107. .mvc,application/x-miva-compiled   

  108. .stl,application/vnd.ms-pki.stl   

  109. .ppsx,application/vnd.openxmlformats-officedocument.presentationml.slideshow   

  110. .xlsb,application/vnd.ms-excel.sheet.binary.macroEnabled.12   

  111. .setpay,application/set-payment-initiation   

  112. .prm,application/octet-stream   

  113. .mix,application/octet-stream   

  114. .lzh,application/octet-stream   

  115. .hhk,application/octet-stream   

  116. .onepkg,application/onenote   

  117. .xaf,x-world/x-vrml   

  118. .flr,x-world/x-vrml   

  119. .IVF,video/x-ivf   

  120. .cnf,text/plain   

  121. .asm,text/plain   

  122. .tiff,image/tiff   

  123. .wax,audio/x-ms-wax   

  124. .ms,application/x-troff-ms   

  125. .tcl,application/x-tcl   

  126. .shar,application/x-shar   

  127. .sh,application/x-sh   

  128. .nc,application/x-netcdf   

  129. .hlp,application/winhlp   

  130. .oda,application/oda   

  131. .pfb,application/octet-stream   

  132. .fla,application/octet-stream   

  133. .wm,video/x-ms-wm   

  134. .rgb,image/x-rgb   

  135. .ppm,image/x-portable-pixmap   

  136. .ram,audio/x-pn-realaudio   

  137. .sit,application/x-stuffit   

  138. .dir,application/x-director   

  139. .mpp,application/vnd.ms-project   

  140. .xla,application/vnd.ms-excel   

  141. .ssm,application/streamingmedia   

  142. .axs,application/olescript   

  143. .ods,application/oleobject   

  144. .psp,application/octet-stream   

  145. .jpb,application/octet-stream   

  146. .wrz,x-world/x-vrml   

  147. .m1v,video/mpeg   

  148. .mno,text/xml   

  149. .cmx,image/x-cmx   

  150. .jpeg,image/jpeg   

  151. .dib,image/bmp   

  152. .rmi,audio/mid   

  153. .aiff,audio/aiff   

  154. .wmd,application/x-ms-wmd   

  155. .wri,application/x-mswrite   

  156. .pub,application/x-mspublisher   

  157. .ins,application/x-internet-signup   

  158. .wks,application/vnd.ms-works   

  159. .xls,application/vnd.ms-excel   

  160. .ai,application/postscript   

  161. .crl,application/pkix-crl   

  162. .qxd,application/octet-stream   

  163. .dwp,application/octet-stream   

  164. .xof,x-world/x-vrml   

  165. .wmv,video/x-ms-wmv   

  166. .nsc,video/x-ms-asf   

  167. .mpa,video/mpeg   

  168. .pnm,image/x-portable-anymap   

  169. .rpm,audio/x-pn-realaudio-plugin   

  170. .aif,audio/x-aiff   

  171. .me,application/x-troff-me   

  172. .pml,application/x-perfmon   

  173. .trm,application/x-msterminal   

  174. .m13,application/x-msmediaview   

  175. .js,application/x-javascript   

  176. .dxr,application/x-director   

  177. .potm,application/vnd.ms-powerpoint.template.macroEnabled.12   

  178. .xltx,application/vnd.openxmlformats-officedocument.spreadsheetml.template   

  179. .xlt,application/vnd.ms-excel   

  180. .xlc,application/vnd.ms-excel   

  181. .p10,application/pkcs10   

  182. .smi,application/octet-stream   

  183. .sea,application/octet-stream   

  184. .hqx,application/mac-binhex40   

  185. .spl,application/futuresplash   

  186. .movie,video/x-sgi-movie   

  187. .lsf,video/x-la-asf   

  188. .txt,text/plain   

  189. .jfif,image/pjpeg   

  190. .jpe,image/jpeg   

  191. .zip,application/x-zip-compressed   

  192. .wmf,application/x-msmetafile   

  193. .m14,application/x-msmediaview   

  194. .latex,application/x-latex   

  195. .wcm,application/vnd.ms-works   

  196. .pptm,application/vnd.ms-powerpoint.presentation.macroEnabled.12   

  197. .xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet   

  198. .hhp,application/octet-stream   

  199. .aca,application/octet-stream   

  200. .accdb,application/msaccess   

  201. .jcz,application/liquidmotion   

  202. .wrl,x-world/x-vrml   

  203. .wmx,video/x-ms-wmx   

  204. .asr,video/x-ms-asf   

  205. .lsx,video/x-la-asf   

  206. .xsl,text/xml   

  207. .html,text/html   

  208. .tif,image/tiff   

  209. .der,application/x-x509-ca-cert   

  210. .pfx,application/x-pkcs12   

  211. .p12,application/x-pkcs12   

  212. .ppsm,application/vnd.ms-powerpoint.slideshow.macroEnabled.12   

  213. .cur,application/octet-stream   

  214. .accdt,application/msaccess   

  215. .hdml,text/x-hdml   

  216. .htm,text/html   

  217. .xbm,image/x-xbitmap   

  218. .jpg,image/jpeg   

  219. .texinfo,application/x-texinfo   

  220. .ppam,application/vnd.ms-powerpoint.addin.macroEnabled.12   

  221. .xlw,application/vnd.ms-excel   

  222. .rm,application/vnd.rn-realmedia   

  223. .pdf,application/pdf   

  224. .rar,application/octet-stream   

  225. .psd,application/octet-stream   

  226. .inf,application/octet-stream   

  227. .emz,application/octet-stream   

  228. .dsp,application/octet-stream   

  229. .onea,application/onenote   

  230. .jck,application/liquidmotion   

  231. .mpe,video/mpeg   

  232. .mp2,video/mpeg   

  233. .sct,text/scriptlet   

  234. .ras,image/x-cmu-raster   

  235. .swf,application/x-shockwave-flash   

  236. .wmz,application/x-ms-wmz   

  237. .gtar,application/x-gtar   

  238. .dcr,application/x-director   

  239. .sldx,application/vnd.openxmlformats-officedocument.presentationml.slide   

  240. .pps,application/vnd.ms-pps   

  241. .p7m,application/pkcs7-mime   

  242. .xsn,application/octet-stream   

  243. .ocx,application/octet-stream   

  244. .accde,application/msaccess   

  245. .mov,video/quicktime   

  246. .wmls,text/vnd.wap.wmlscript   

  247. .cpp,text/plain   

  248. .c,text/plain   

  249. .bas,text/plain   

  250. .css,text/css   

  251. .art,image/x-jg   

  252. .mp3,audio/mpeg   

  253. .t,application/x-troff   

  254. .roff,application/x-troff   

  255. .tar,application/x-tar   

  256. .hhc,application/x-oleobject   

  257. .scd,application/x-msschedule   

  258. .pko,application/vnd.ms-pki.pko   

  259. .sst,application/vnd.ms-pki.certstore   

  260. .ppt,application/vnd.ms-powerpoint   

  261. .xtp,application/octet-stream   

  262. .u32,application/octet-stream   

  263. .pcx,application/octet-stream   

  264. .msi,application/octet-stream   

  265. .exe,application/octet-stream   

  266. .asd,application/octet-stream   

  267. .onetoc2,application/onenote   

  268. .fif,application/fractals   

  269. .mpg,video/mpeg   

  270. .vml,text/xml   

  271. .xdr,text/plain   

  272. .vcs,text/plain   

  273. .hxt,text/html   

  274. .eml,message/rfc822   

  275. .xpm,image/x-xpixmap   

  276. .ico,image/x-icon   

  277. .gif,image/gif   

  278. .dwf,drawing/x-dwf   

  279. .src,application/x-wais-source   

  280. .tr,application/x-troff   

  281. .pmr,application/x-perfmon   

  282. .pma,application/x-perfmon   

  283. .dll,application/x-msdownload   

  284. .bcpio,application/x-bcpio   

  285. .wmlc,application/vnd.wap.wmlc   

  286. .wdb,application/vnd.ms-works   

  287. .dotx,application/vnd.openxmlformats-officedocument.wordprocessingml.template   

  288. .docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document   

  289. .pot,application/vnd.ms-powerpoint   

  290. .xltm,application/vnd.ms-excel.template.macroEnabled.12   

  291. .rtf,application/rtf   

  292. .prf,application/pics-rules   

  293. .snp,application/octet-stream   

  294. .cab,application/octet-stream   

  295. .avi,video/x-msvideo   

  296. .asf,video/x-ms-asf   

  297. .dtd,text/xml   

  298. .wml,text/vnd.wap.wml   

  299. .vbs,text/vbscript   

  300. .rtx,text/richtext   

  301. .dlm,text/dlm   

  302. .xwd,image/x-xwindowdump   

  303. .pgm,image/x-portable-graymap   

  304. .bmp,image/bmp   

  305. .crt,application/x-x509-ca-cert   

  306. .ustar,application/x-ustar   

  307. .tex,application/x-tex   

  308. .sv4cpio,application/x-sv4cpio   

  309. .tgz,application/x-compressed   

  310. .cdf,application/x-cdf   

  311. .vss,application/vnd.visio   

  312. .cat,application/vnd.ms-pki.seccat   

  313. .thmx,application/vnd.ms-officetheme   

  314. .xlsm,application/vnd.ms-excel.sheet.macroEnabled.12   

  315. .prx,application/octet-stream   

  316. .pcz,application/octet-stream   

  317. .onetmp,application/onenote   

  318. .acx,application/internet-property-stream   

  319. .wsdl,text/xml   

  320. .disco,text/xml   

  321. .xsd,text/xml   

  322. .wbmp,image/vnd.wap.wbmp   

  323. .png,image/png   

  324. .pnz,image/png   

  325. .smd,audio/x-smd   

  326. .smz,audio/x-smd   

  327. .smx,audio/x-smd   

  328. .mmf,application/x-smaf

IE8下载docx文件发现后缀变为.zip文件

标签:nginx

原文地址:http://pengweinan.blog.51cto.com/4777987/1717018

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!