← Back to Upcase

Download .html file instead of opening in browser with link_to


(Gurban Haydarov) #1

I have this code:

<%= link_to "download", "https://region.amazonaws.com/bucket/file.html" %>

I want to download this file as it is, instead of opening it in browser. Any ideas? Thanks!


(Lenart Rudel) #2

Read here about possible options. In short:

  • server should respond with correct response headers in order for browser to recognise the file should be downloaded (and not displayed)

  • use HTML5 <a href="file.html" download="myfile.html"> attribute (not supported in IE and Safari)


(Gurban Haydarov) #3

Thanks Lenart, that helped.