I'd like to serve static content from a controller action in Rails the same way that Rails serves static content out of the public directory. I do not want to just change the path of the public directory or add another path to Rails to serve files from there. I want to explicitly handle requests to specific files in a controller to verify the request depending on the requested files.
I naively tried to use send_file
but then I can not use range requests anymore.
class MyController < ApplicationController
def dummyAction
filePath = 'foo/bar/baz.mp3'
send_file(filePath, {:filename => "baz.mp3", :type => "audio/mpeg"})
end
end
I'd prefer to use Rails instead of writing all the code myself. Is there something in Rails to do this? Maybe a Gem?