Created
September 28, 2010 15:21
-
-
Save directionless/601183 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/ruby | |
# Note that this takes about 100 minutes to run. | |
require 'rubygems' | |
require 'aws/s3' | |
LOCAL_FILE=ARGV[0] | |
BUCKET=ARGV[1] | |
REMOTE_FILE=ARGV[2] | |
if LOCAL_FILE == nil or BUCKET == nil or REMOTE_FILE == nil | |
puts "Syntax Error. Call as:" | |
puts " s3-put.rb <local file> <bucket> <remote_file>" | |
exit 1 | |
end | |
if ENV['AWS_ACCESS_KEY_ID'] == nil or ENV['AWS_SECRET_ACCESS_KEY'] | |
puts "Missing AWS credentials ENV" | |
exit 2 | |
end | |
AWS::S3::Base.establish_connection!( | |
:use_ssl=>true, | |
:server=>"s3.amazonaws.com", | |
:port=>443, | |
:access_key_id=>ENV['AWS_ACCESS_KEY_ID'] | |
:secret_access_key=>ENV['AWS_SECRET_ACCESS_KEY'] | |
:proxy => { :host => '10.41.100.19', :port => 3128 } | |
) | |
if AWS::S3::S3Object::exists? REMOTE_FILE, BUCKET | |
puts "ERROR: remote files exists. Wha?" | |
exit 1 | |
end | |
AWS::S3::S3Object.store( | |
REMOTE_FILE, | |
open(LOCAL_FILE), | |
BUCKET, | |
:content_type => 'binary/octet-stream', | |
:access => :private | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment