Created
April 7, 2009 15:24
-
-
Save cdollins/91288 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
# This is a simple command line tool for uploading | |
# and folders of files to AWS S3. You must first | |
# create a vaild bucket to upload to. | |
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'pathname' | |
require 'aws/s3' | |
include AWS::S3 | |
if ARGV.size < 2 | |
p "Usage: s3cli.rb bucket file ..." | |
exit | |
end | |
Base.establish_connection!( | |
:access_key_id => 'public', | |
:secret_access_key => 'private' | |
) | |
bucket = ARGV.shift | |
begin | |
Bucket.find(bucket) | |
rescue ResponseError => error | |
p error.message | |
exit 0 | |
end | |
ARGV.each do |name| | |
file = Pathname.new(name) | |
if file.file? | |
S3Object.store(file.basename.to_s, file.open, bucket) | |
elsif file.directory? | |
ARGV.concat file.children | |
else | |
p "#{file} does not exist" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment