Ok,that was easy to do :
First add a route for the corresponding urls :
match '/opt/myapp/uploads/:file_name' => 'files#serve'
The create a FilesController with a serve method :
class FilesController < ApplicationController
def serve
before_filter :authenticate_user! #used with Devise to protect the access to the images
path = "/opt/myapp/uploads/#{params[:file_name]}.png"
send_file( path,
:disposition => 'inline',
:type => 'image/png',
:x_sendfile => true )
end
end
Then I needed to add this line in my development.rb and production.rb configuration files :
config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" #to use with Thin and Nginx