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

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;
	}
}
1 Like

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?

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

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.

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.

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

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"';
}

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

1 Like

Current tests with MIME-types brought me back to this topic. This did work well for me. I’d not recommend the way I posted a few years ago anymore.

However, Cast Feed Validator doesn’t fancy downloads as an attachment and returns the following error:

ERROR: Your media file downloads as an attachment and won’t be compatible with all devices.

Note: I have yet to see a service/device that is unable to play one of my episodes because of them being downloaded as an attachment.