views:

534

answers:

3

I know how to change the MIME type in a webserver. I used this to make sure the browser downloads my .scrpt file instead of opening the plain text version. So far so good but is it possible to do the same with a link? I would like to link to a file on GitHub but this will open as a plain text file. Can I add a "MIME type attribute" to the link to tell the browser to download the file?

This is what I would like to see:

<a mimetype="application/octet-stream" href="http://gist.github.com/raw/279094/39d5a2c1037288d5ee0ba1a17dca9edb368bbe42/RepairiPhotoDates.scpt"&gt;download&lt;/a&gt;
+3  A: 

You can specify a type attribute, but the content-type sent by the server is authoritative.

This attribute gives an advisory hint as to the content type of the content available at the link target address. It allows user agents to opt to use a fallback mechanism rather than fetch the content if they are advised that they will get content in a content type they do not support.

Other than that, no, you can't.

David Dorward
I tried this but it does not work. As you explained... Thanks for the clear explanation.
Cimm
A: 

HTML is not concerned about the HTTP response headers. This is absolutely a server-side problem, which has to be solved in the HTTP repsonse headers before the HTTP reponse body(/content?) is sent. Without a scripting language like Ruby or PHP there is nothing you can do.

Labuschin
A: 

Can you set up a middleman script which downloads the file in question to the server, then uploads it to the user with a different MIME type?

Axidos