content type for mp3 download response

Vihaan Verma picture Vihaan Verma · Aug 18, 2012 · Viewed 72.8k times · Source

I have created a simple HTTP server which allows users to download files. But this does not seem to work for mp3 files. The content type currently is "application/misc". In order to make it work with mp3 files , I've tried "application/mp3" , "application/data" and "application/mpeg".

What would be the right content type for mp3 or audio file download, and am I missing some other headers?


EDIT: The file should automatically start downloading rather than prompting the user for saving it somewhere.

Answer

jamjam picture jamjam · Aug 18, 2012

Try "Content-Type: audio/mpeg"

Update

To encourage the browser to download the mp3 rather then streaming, do

Content-Disposition: filename="music.mp3"'