Resource interpreted as Document but transferred with MIME type application/zip

后端 未结 18 2289
不思量自难忘°
不思量自难忘° 2020-11-27 10:54

With Chrome 12.0.742.112, if I redirect with the following headers:

HTTP/1.1 302 Found 
Location: http://0.0.0.0:3000/files/download.zip
Content-Type: text/h         


        
相关标签:
18条回答
  • 2020-11-27 11:34

    I experienced this problem when serving up a PDF file (MIME type application/pdf) and solved it by setting the Content-Disposition header, e.g.:

    Content-Disposition: attachment; filename=foo.pdf
    

    Hope that helps.

    0 讨论(0)
  • 2020-11-27 11:34

    I've fixed this…by simply opening a new tab.

    Why it wasn't working I'm not entirely sure, but it could have something to do with how Chrome deals with multiple downloads on a page, perhaps it thought they were spam and just ignored them.

    0 讨论(0)
  • 2020-11-27 11:34

    Just ran into this and none of the other information I could find helped: it was a stupid error: I was sending output to the browser before starting the file download. Surprisingly, I found no helpful errors found (like "headers already sent" etc.). Hopefully, this saves someone else some grief!

    0 讨论(0)
  • 2020-11-27 11:34

    I got the same error, the solution was to put the attribute

    target = "_ blank"
    

    Finally :

    <a href="/uploads/file.*" target="_blank">Download</a>
    

    Where * is the extension of your file to download.

    0 讨论(0)
  • 2020-11-27 11:37

    I encountered this when I assigned src="image_url" in an iframe. It seems that iframe interprets it as a document but it is not. That's why it displays a warning.

    0 讨论(0)
  • 2020-11-27 11:38

    You can specify the HTML5 download attribute in your <a> tag.

    <a href="http://example.com/archive.zip" download>Export</a>
    

    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download

    0 讨论(0)
提交回复
热议问题