Skip to content

Instantly share code, notes, and snippets.

@swalberg
Created July 17, 2012 19:18
Show Gist options
  • Save swalberg/3131385 to your computer and use it in GitHub Desktop.
Save swalberg/3131385 to your computer and use it in GitHub Desktop.
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