I have the following problem. Sounds are hidden from the public folder, cause there are only certain Users who should have access to the sound files. So I made a certain method, which acts like a sound url, but calculates first, whether the current user is allowed to access this file.
The file gets sent by the send_data method. The problem is just, that I it works quite slow if it works even... The developer of the jplayer plugin, which I use to play the sound, told me that I should be able to accept byte range requests to make it work properly...
How can I do this within a rails controller by sending the file with send_data or send_file?
Thanks, Markus
Here is my version. I use gem 'ogginfo-rb' to calculate the duration which is required to serve ogg files properly. p.s. I always have three formats - wav, mp3, ogg.
I used Garrett's answer and modified it (including one or two bug fixes). I also used
send_data
instead of reading from a file:Another amended version - I was trying to download a zip file as binary content and this is what worked for me -
I've been able to serve up the files with some success using send_file. Although I have one hitch, seeking to an earlier part of the song causes a new request which makes the song restart from 0:00 instead of the true location from the seekbar. This is what I have working for me so far: