Created
July 17, 2012 19:18
-
-
Save swalberg/3131385 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'rubygems' | |
require 'aws/s3' | |
require 'base64' | |
# Override the authorization header | |
module AWS | |
module S3 | |
class Connection #:nodoc: | |
def authenticate!(request) | |
ignore = Authentication::Header.new(request, access_key_id, secret_access_key) | |
request['Authorization'] = "Basic " + Base64.strict_encode64("username:password") | |
request['Host'] = 'a1.cloudgate.ca' | |
end | |
end | |
end | |
end | |
class AWS::S3::S3Object | |
class << self | |
alias_method :original_path!, :path! | |
def path!(bucket, name, options = {}) #:nodoc: | |
'/s3' + original_path!(bucket, name, options) | |
end | |
end | |
end | |
AWS::S3::Base.establish_connection!( | |
:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'], | |
:secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY'], | |
:server => 'a1.cloudgate.ca' # Override the server we go to | |
) | |
puts AWS::S3::S3Object.store('test123', open('test.txt'), 'loadtest') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment