Download audio using HTML5 Download attribute in Rails

I found so many overcomplicated solutions to solve this, so I wanted to share a simplistic solution that I use.

My goal: Let the user download an audio file that is stored in AWS by clicking on a download icon.

This solution above uses a FontAwesome shortcut and the HTML5 download attribute on my Song show page. I use carrierwave to upload my media to AWS.

First, I make a link to the icon. Then, I use my song’s url that’s stored in AWS as the destination url (audio is the column I use in my Song database). Lastly, I use the HTML5 download attribute and call the current song’s audio. Nice and simple!

(Visited 88 times, 1 visits today)