Skip to content

Instantly share code, notes, and snippets.

@mhgbrown
mhgbrown / image_proxy_controller.rb
Last active November 8, 2022 15:09
Proxy images through a Rails controller
require 'base64'
require 'net/http'
class ImageProxyController < ActionController::Base
def get
url = URI.parse(Base64.decode64(params[:url]))
image = Net::HTTP.get_response(url)
send_data image.body, type: image.content_type, disposition: 'inline'
end
end