Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I'm serving a binary file (.IPA) with Ubuntu/Apache 2.2. When I have chosen Save Linked File As... in Safari, it says it's text file. And it guides me to add .txt extension. However it does not add any extra extension when I download it just clicking link.

I added line AddType application/octet-stream .ipa in apache configuration file. I don't know what's wrong with this. Is this a bug of Safari or my misconfiguration? (1) If it caused by bug, how can I avoid this? (2) Or if it caused by misconfiguration, what should I do?

share|improve this question

migrated from serverfault.com May 2 '11 at 10:32

This question came from our site for professional system and network administrators.

1  
This sounds like it might be a Safari bug. If your is is sending the right ContentType header so that it saves when normally clicked, I can't see how it wouldn't be sending the same header when the browser requests it through it's little save file mechanism. Have you searched around to see if Safari user forums have any complains about this behavior in general? –  Caleb May 2 '11 at 18:23
    
@Caleb I realized I have to do anything to avoid this even it caused by Safari bug.... Thanks anyway. –  Eonil May 3 '11 at 2:41
1  
@Eonil I understand your situation but chasing the Safari bug might lead you to somebody who has found a workaround. BTW, have you tested this in other browsers to see what their behavior is? –  Caleb May 3 '11 at 7:27
    
Thanks again. I'll try to track Safari bug to find something. I didn't tested Chrome, and it downloaded the file with no problem. –  Eonil May 3 '11 at 8:10
    
I would also check Firefox, Opera, and anything else you come across just to see if there is any inconsistency with your server. You might also use something like Firebug to look at the headers that get served when the file is downloaded via a direct hit vs a download-save-as type command. –  Caleb May 3 '11 at 8:14
show 1 more comment

1 Answer 1

It is caused by Safari's behaviour and can be avoided by using JavaScript to disable context menus:

var browser = navigator.userAgent;
if (browser.toLowerCase().indexOf('safari') > 0)
{
    var allLinks = document.body.getElementsByTagName('a');
    for (var i=0; i<allLinks.length; i++) {
        allLinks[i].oncontextmenu = function() { return false };
    }
}
share|improve this answer
    
This just degrades usability, does not solve or avoid the problem. –  Eonil Jun 20 '11 at 17:41
    
Unless you convince Safari users to change their browser, or Apple to adjust the behaviour then you'll need to decide whether to disable context menus for links in Safari or educate users to remove the .txt suffix for unknown filetypes. Its not possible to have your cake and eat it in this situation. This solution just stops the context menu (the method of triggering this unwanted download behaviour) in Safari browsers. –  Metalshark Jun 21 '11 at 11:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.