content type for mp3 download response
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.
Try "Content-Type: audio/mpeg"
Update
To encourage the browser to download the mp3 rather then streaming, do
Content-Disposition: filename="music.mp3"'
.mp3 audio/mpeg3
.mp3 audio/x-mpeg-3
.mp3 video/mpeg
.mp3 video/x-mpeg
Using Content-Disposition: attachment... forces a download box to appear instead of having to right click -> save target as.
After a lot of research, I found some resources (some on SO) that led to this solution. It is the most cross device compatible solution out there and solves a lot of issues especially with Android devices (a lot of issues with them apparently).
Content-Disposition: attachment; filename="my_mp3_filename.MP3"
Take note of the upper-case extension. That is important.
Using Content-Type "application/force-download"
worked for me.
try below content type it worked for me.
"audio/mpeg3;audio/x-mpeg-3;video/mpeg;video/x-mpeg;text/xml"