[Podlove Publisher] How to enable Force Downloads & Fix Mime Types


#1

Summary

Download servers usually deliver media files “as is” to a browser. Most of the times, browsers tend to try to open the files directly offering immediate playback. As web players are common these days, this behaviour is not ideal as most users expect the content to be downloaded to disk directly.

In order to enable forced downloads, you need to change the configuration of your download server. The video shows how to do that and you will find example configurations for Apache and nginx web servers below.

Apache Config

<FilesMatch "\.(mp3|m4a|ogg|oga|opus|flac)$">
	Header set Content-Disposition "attachment"
</FilesMatch>
 
AddType audio/mpeg mp3
AddType audio/mp4  m4a
AddType audio/ogg  oga ogg
AddType audio/opus opus
AddType audio/flac flac

nginx Config

location ~* (mp3|m4a|ogg|oga|opus|flac)$ {
    add_header Content-Disposition "attachment; filename=$1";
}

http {
	types {
		audio/mpeg mp3;
		audio/mp4  m4a;
		audio/ogg  oga ogg;
		audio/opus opus;
		audio/flac flac;
	}
}

V4: Download Link -> Save as
Customising the Download Interface | Publisher Weekly #2
#2

Hi Eric!

Thank you for this explanation! This does what I was looking for. To handle this, my host offers two separate interfaces that are somewhat simpler. Still I’m not 100% sure what I’m doing. Therefore I’d like to ask the expert first.

The Apache interface asks for a file-extension and a “handler”. I only offer .mp3 podcast files. So the file extension will be .mp3 I guess? But what “Handler” should I add?


#3

I assume you can skip the handler. Just fill out the MIME form with “audio/mpeg” and “mp3”.


#4

A lot of meme types are already set. Here an excerpt oft the relevant ones:

Therefore I assume that the MIME-Types are already good to go. The only thing missing must be the Apache part.


#5

Well, since the MIME type is already configured it should work. However, I don’t know what software you are using to configure Apache and how it behaves. Please contact your hoster.


#6

Thanks for your response. I did.

If anyone should come across this post searching for the solution to a similar problem, here is what I had to do:

  • MIME-Type: application/data
  • Extension: mp3

#7

#8

When using the proposed nginx config, the file names of the downloads are changed to only the file extension, e.g. “mp3” “m4a” etc.

This works for me and preserves the file names:

location ~ ^.*/(?P[^/]+\.(mp3|m4a|psc))$ {  
    add_header Content-Disposition 'attachment; filename="$request_basename"';
}

#9

For those who do not have access to your apache config.

You can “force” the “Save As” Dialog as well in .htaccess. Here is the code that worked for me:

<FilesMatch “.(mp3|m4a|ogg|oga|opus|flac)$”>
Header set Content-Disposition “attachment”

AddType audio/mpeg mp3
AddType audio/ogg oga ogg