in Projects, Programming, Technology

Ruby: using send_file and send_data to relay files from one site through another

 
Cache and relay images using:

require 'uri'

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

Write a Comment

Comment