in Projects, Programming, Technology

send_file and remote files – Ruby on Rails code

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

  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