in Projects, Programming, Technology

Using rails send_file to proxy remote files

require 'uri'

class ImagesController < ApplicationController
# relays remote images so that we can encrypt them
def index
data = open(params[:src])
:type => data.content_type,
:disposition => 'inline'

Here is how to proxy an image from an HTTP server to a client using ruby on rails. This is useful when trying to proxy a request from an insecure server when your server is hosted over SSL.

Write a Comment


  1. I am relatively new to rails.
    I was trying to let clients download using send_file from amazon s3. It was not working probably because send_file cannot work with remote files/urls.
    I was desperately searching for a solution.
    Your post has saved me. Thanks