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.
An mp3 is the most popular type of lossy audio—that is a digital audio file that has been compressed to a manageable size for storage, streaming, and downloads. Smartphones and tablets play mp3 files. The mp3 compression algorithm does result in a loss of quality compared to the original analog audio files.
MP3 (MPEG-1 Audio Layer-3) is a standard technology and format for compressing a sound sequence into a very small file (about one-twelfth the size of the original file) while preserving the original level of sound quality when it is played. MP3 files (identified with the file name suffix of ".
This answer is not useful. Show activity on this post. Content-Type: application/force-download means "I, the web server, am going to lie to you (the browser) about what this file is so that you will not treat it as a PDF/Word Document/MP3/whatever and prompt the user to save the mysterious file to disk instead".
Try "Content-Type: audio/mpeg"
Update
To encourage the browser to download the mp3 rather then streaming, do
Content-Disposition: filename="music.mp3"'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With