Skip to content

Instantly share code, notes, and snippets.

@semaperepelitsa
Created July 17, 2013 20:54
Show Gist options
  • Save semaperepelitsa/6024403 to your computer and use it in GitHub Desktop.
Save semaperepelitsa/6024403 to your computer and use it in GitHub Desktop.
Testing Fog over HTTP Proxy
gem "dragonfly", "~> 0.9.14"
require "dragonfly"
img = Dragonfly[:images]
img.datastore = Dragonfly::DataStorage::S3DataStore.new(
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
bucket_name: ENV['S3_BUCKET_NAME']
)
begin
img.fetch('123.jpg').apply
rescue Dragonfly::DataStorage::DataNotFound
puts "OK"
end
if ARGV.first == "stable"
gem 'excon', '~> 0.16.10'
gem 'fog', '~> 1.8.0'
else
gem 'fog', '~> 1.12.0'
end
require "fog"
s3 = Fog::Storage.new(
provider: "AWS",
region: "eu-west-1",
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
)
begin
obj = s3.get_object(ENV['S3_BUCKET_NAME'], "123.jpg")
rescue Excon::Errors::NotFound
else
p obj.body.length
end
puts "OK"
require "open-uri"
open("https://www.google.com")
puts "OK"
require "webrick/httpproxy"
server = WEBrick::HTTPProxyServer.new Port: 8099
trap(:INT){ server.shutdown }
server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment