Warning when setting window.location to download a file

4k Views Asked by At

I am setting the window.location to download a file ("/foo/bar"). Now, the download works in google chrome, but it emits this warning:

Resource interpreted as Document but transferred with MIME type application/csv:

These are the response headers that are set according to google chrome:

Content-Description:File Transfer  
Content-Disposition:attachment; filename="foo.csv"  
Content-Length:29  
Content-Type:application/csv
Date:Sun, 14 Dec 2014 20:53:33 GMT  
Server:http-kit  

Any ideas if I can set the accept header on js side anyhow to omit this warning?

1

There are 1 best solutions below

6
Edwin Reynoso On BEST ANSWER

You can use an anchor tag

<a href="fileLink" download="filename">Download</a>

make sure for the download attribute you put the extension type of the file like .html, .css, .js whatever it is