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">download</a>
Look for a <meta> element in the page source that gives the MIME type, for example <meta http-equiv="Content-Type" content="text/html"> . According to the standards, the <meta> element that specifies the MIME type should be ignored if there's a Content-Type header available.
In the Connections pane, go to the site, application, or directory for which you want to add a MIME type. In the Home pane, double-click MIME Types. In the MIME Types pane, click Add... in the Actions pane. In the Add MIME Type dialog box, add the file name extension and MIME type, and then click OK.
A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.
Time to answer my own question. This is a really old question and it probably wasn't possible at the time but lots has changed since then. The HTML5 spec added the download
attribute:
<a href="hugepdf.pdf" download>Download file</a>
This will do exactly what I need, tell the browser to download the file instead of opening it. Thanks to Jonathan Svärdén for solving my years old question!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With