Geeks and God Podcast

(206)984-3694geeksandgod@gmail.comfeeds.feedburner.com/geeksandgod
login | register

Force Browser to Download MP3's

Does anyone know how to force the browser to popup the "save as" dialog box when user clicks on a link to a MP3? This is currently what happens on the Geeks&God website.

I have tried adding this to my .htaccess on the server in the directory that contains the MP3 files:

AddType application/octet-stream .mp3

<Files *.mp3>
ForceType application/octet-stream
Header set Content-Disposition attachment
</Files>

The above directives work for Firefox but not IE7. I have tried each directive alone as well as together in the .htaccess file.

Any help would be appreciated.

Thanks,

Justin

A browser thing...I think

Hey Justin...
It may be because I'm a dummy, but I'm pretty sure this is just a browser thing. I know in most browsers, if you link to the mp3 directly, it will ask you to download it (as long as the browser doesn't try to play it through a player plugin).

That's all we have here. Granted, I think the Audio module is generating that link, but still, I'm pretty sure it's just a standard link to the original mp3 file.

-Rob Feature
Geeks and God Co-Host
www.bobchristenson.com

Flumoxed

I just don't get it. On Geeks & God, when I click on the download MP3 links, the File Download dialog box pops up in both Firefox2 and IE7. When I click on the same type of link on my own site, http://www.hopechapelsterling.... ,(same computer, same browsers) the mp3 loads in the browser using a plugin (i.e. Quicktime or Media Player). Depending which computer I use the behavior changes. Firefox plays the mp3 in the browser at home but downloads to disk at work. IE does just the opposite.

I find it very interesting that it works consistently on Geeks & God but not on my site. Ugh!

Thanks for trying,
-Justin

browser based settings for mp3 downloads

Not sure about getting the server to force a download (though it would be nice to know that), but you could use my video how to get Firefox to download wmv files and just change the wmv to mp3.

http header

The reason that it always pops up and asks to save with the audio module is that the audio module sets the http header for the file to be something that forces it to download.

Some of the http header elements that it custom sets are Content-Type, Content-Length, and Content-Disposition with Content-Disposition being set (among other things) as an attachment.

You can read the spec here: http://www.w3.org/Protocols/rf...

This is what makes the pop-up box work.

The reason your fix didn't work is because IE doesn't take the server at it's word, reads the files mime type, and does what it would normally do. Your best bet is to do something like what the audio module does (using something like php, asp, perl, python, etc.) and force the http headers.

Matt Farina
Geeks and God Co-Host
www.mattfarina.com

Plan B

Thanks for the response. I was hoping to not go that route but I guess I will have to anyway. I wanted the link to be a direct link to the file and not to a backend script. It just seems less clean to me. Such is life.

Just so I fully understand, is it true then that the links to mp3's on G&G are not direct (even though they appear that way to the browser) and are actually handled by Drupal and the Audio module?

-Justin

Correct

Hey Justin...
You are correct...All the links for our downloads are handled directly by the Audio module in drupal (except for old episodes...you'll notice a different style flash player on those and they were hard coded links).

I just wasn't aware that they had some php magic behind them....all hail MF for his supreme geekyness....

-Rob Feature
Geeks and God Co-Host
www.bobchristenson.com

Another IE Issue

The audio module does do some php magic. It isn't a simple redirect. It's even more than dealing with the header... it actually allows us to keep stats on the files.

The reason you can't link directly to the mp3s is a function of IE. Where the server tells it to download the file IE decides otherwise. The scripting (PHP, Perl, ASP, etc.) is really a work around due to another fun filled 'feature' in IE.

Matt Farina
Geeks and God Co-Host
www.mattfarina.com

Forcing download of MP3 files

Justin,

We accomplished this for our podcast feed by setting the MIME TYPE to application/force-download for MP3 files.

Web Servant of the Most High God

<>< <>< <>< <>< <>< <><

My motto and life's goal:
"Simple obedience to God in the simple things." †

noperz

You might not realize this but in my IE on a PC qucktime just plays your file. I'm not prompted to download. Works fine in my mac but not on my PC.... darn IE.

So, when it your cast going to bring me a new episode?

Matt Farina
Geeks and God Co-Host
www.mattfarina.com

don't stop users getting at the mp3 url though

Just a quick request....in whatever you end up doing, please don't make it hard for users to get to the actual url of the mp3: I've just had a fight with a church web site trying to get to the mp3 url of their latest sermon. I wanted to share it with others (on Facebook), but they were using redirect urls, so it wasn't immediately obvious where the mp3 was. I had to open their "listen now" page, which embedded the mp3, then use Firefox's "View page info" option, and go to the media tab to see where the mp3 was. I could have gone to view source too, but our net connection in slow at the moment, so that wasn't working for me.

slow down there

You are right that users should have access to a url to the audio file. But, that doesn't mean the url has to be a direct link to the file.

On the Geeks and God site users don't have direct access to the file but they do have access to a link to the file. By passing the mp3 through the site we can do all sorts of good things and still leave a link that lets you get through to the file.

Matt Farina
Geeks and God Co-Host
www.mattfarina.com

Files are External

what about if the files are external links. we have a podcast and we save the files on archive.org and I want to use the download link for users to download the mp3s.

A little hacking

Sadly, files on a different server is not supported right now :-(

What you would have to do is combine a few other modules together with a url style field from CCK being one of them or get into some custom coding.

Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com