Created
July 17, 2013 20:54
-
-
Save semaperepelitsa/6024403 to your computer and use it in GitHub Desktop.
Testing Fog over HTTP Proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "open-uri" | |
open("https://www.google.com") | |
puts "OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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