Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
436 views
in Technique[技术] by (71.8m points)

javascript - 资源被解释为文档,但以MIME类型application / zip传输(Resource interpreted as Document but transferred with MIME type application/zip)

With Chrome 12.0.742.112, if I redirect with the following headers:(对于Chrome 12.0.742.112,如果我使用以下标头重定向:)

HTTP/1.1 302 Found Location: http://0.0.0.0:3000/files/download.zip Content-Type: text/html; charset=utf-8 Cache-Control: no-cache X-Ua-Compatible: IE=Edge X-Runtime: 0.157964 Content-Length: 0 Server: WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18) Date: Tue, 05 Jul 2011 18:42:25 GMT Connection: Keep-Alive Which if followed returns the following header:(如果遵循,则返回以下标头:) HTTP/1.1 200 OK Last-Modified: Tue, 05 Jul 2011 18:18:30 GMT Content-Type: application/zip Content-Length: 150014 Server: WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18) Date: Tue, 05 Jul 2011 18:44:47 GMT Connection: Keep-Alive Chrome will not redirect, nor change the previous page, it'll just report the following warning in the console:(Chrome不会重定向,也不会更改上一页,它只会在控制台中报告以下警告:) Resource interpreted as Document but transferred with MIME type application/zip.(资源被解释为文档,但以MIME类型application / zip传输。) The process works correctly in Firefox, and also works fine in Chrome if I open a new tab and go directly to http://0.0.0.0:3000/files/download.zip .(如果我打开一个新标签页并直接转到http://0.0.0.0:3000/files/download.zip ,则该过程在Firefox中可以正常运行,在Chrome中也可以正常运行。) Am I doing something wrong, or is this a bug/quirk of Chrome?(我是在做错什么,还是Chrome的错误/怪癖?)   ask by Ashley Williams translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can specify the HTML5 download attribute in your <a> tag.(您可以在<a>标记中指定HTML5 下载属性。)

<a href="http://example.com/archive.zip" download>Export</a> https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download(https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/a#attr-download)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...