So I have a ~40MB .wav file that users are downloading with the click of a button. The markup looks like this:
<div class="row">
<div class="col-md-6">
<%= link_to "Download Single", download_song_path, class: "btn btn-default btn-custom" %>
</div>
<div class="col-md-6">
<%= link_to "Download Artwork", download_artwork_path, class: "btn btn-default btn-custom" %>
</div>
</div>
And the controller is this:
class WelcomeController < ApplicationController
def index
end
def download_song
send_file "#{Rails.root}/public/white-flame.wav", :x_sendfile => true, :type=>"audio/wav", :filename => "white-flame.wav"
end
def download_artwork
send_file "#{Rails.root}/public/white-flame-artwork.jpg", :x_sendfile => true, :type=>"image/jpg", :filename => "white-flame.jpg"
end
end
The artwork download works fine, it's only a ~2MB file, but the .wav file literally takes 20 seconds or so just for the download dialog to display. What's the issue? I just want the user to be able to click "Download" and it download.