This project is read-only.

Download Media Link (mp3 audio file)

Topics: Customizing Orchard, General
Aug 27, 2013 at 2:43 AM
I am using the Media library in Orchard 1.7 to manage mp3 audio files. I have content items using the Media Library Picker Field. When displaying the content item, the Media Library Picker shape renders the audio player, but I would also like to provide a download link for the mp3 file.

I think in most browsers, linking to a .mp3 file will activate the browser's built-in streaming audio plugin. I think I need a way to respond to download requests with Content-type: octet/stream

Will I need to write a custom controller to accomplish this, or is there some existing functionality in Orchard that can handle this?
Aug 27, 2013 at 2:59 AM
I think it should just be a matter of properly configuring IIS mime types...
Aug 27, 2013 at 10:44 PM
Bertrand thanks for the quick reply. I forgot to mention a key detail... I am hosting Orchard using Azure cloud service and my media is being served from Azure storage. After digging in some, I did notice that the ConfigurationMimeTypeProvider is looking for mime mappings in the web.config in order to provide the proper mime type for uploaded media. I have added mime mapping configuration to the system.webServer section of the web.config as shown below:
      <remove fileExtension=".mp3"/>
      <mimeMap fileExtension=".mp3" mimeType="application/octet-stream" />
I have republished including the web.config change, and uploaded some new media files, but I still see that the Content Type = audio/mpeg in the file properties for my uploaded mp3 files in blob storage.

I am still trying to work through this, but thought I would give an update. Please let me know if I am headed the wrong direction or if I am missing something.
Aug 27, 2013 at 11:46 PM
Sounds like the way to go yes.