Reputation: 8384
When users visit our website's download page, it automatically starts the download. The page has a display:hidden
iframe with src
pointing to the installer file:
<iframe src="/path/to/installer.dmg"></iframe>
This works fine so far. But my Chrome extension: "Web developer" logs this Warning message
Resource interpreted as Document but transferred with MIME type application/octet-stream
So, is there a way to explicitly declare installer.dmg's content-type as octet-stream
, so that browsers do not get confused?
Upvotes: 9
Views: 43344
Reputation: 5912
The problem is that you are using an installer file as a web page.
What you can do is open the installer page in a popup on document ready.
You can read this (with jQuery):
Or this (no jQuery):
Upvotes: -2
Reputation: 2278
This page has what you need, if your web server is Apache.
Basically what you do is tell apache that any file with a DMG extension has the mime-type
of application/octet-stream
.
Upvotes: -2
Reputation: 5828
As one of the previous answers references a broken link I will give my answer here.
If you are trying to specify the mime type of files with a certain extension you can add this to .htaccess
:
AddType application/octet-stream .dmg
However, this will not guarantee that browsers will 'download' the file. Chrome for example does not recognise this. So here is a way to force files of a certain type to 'download':
<FilesMatch "\.(?i:dmg)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
The little bit of regex around the extension (DMG) is just there to make it case insensitive.
You might need to clear browser cache before it works correctly.
This works in the latest Chrome, Firefox and Internet Explorer 8 (as of August 2013). I have not tested in the latest Internet Explorer or Safari, so if someone has those browsers and can test them, please confirm they work in the comments below.
Upvotes: 15
Reputation: 1
Insert those lines in your vhost configuration, inside a docroot directory:
<Directory path/of/your/docroot/directory>
<Files path/of/your/file>
Header set Content-type "mime/type"
</Files>
</Directory>
Upvotes: 0