Created
June 5, 2011 13:03
-
-
Save thechrisoshow/1008942 to your computer and use it in GitHub Desktop.
This script uploads files to a S3 bucket
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 'rubygems' | |
require 'aws/s3' | |
# Change the access key and secret to your amazon credentials | |
AWS::S3::Base.establish_connection!( | |
:access_key_id => 'ACCESS_KEY_ID', | |
:secret_access_key => 'SECRET' | |
) | |
# Change this to your S3 bucket name | |
WEBSITE_BUCKET_NAME = "YOUR_BUCKET_NAME" | |
# Will raise an error if bucket doesn't exist | |
AWS::S3::Bucket.find WEBSITE_BUCKET_NAME | |
Dir["*"].each do |file| | |
# Don't upload this file! | |
if file != __FILE__ | |
print "Uploading #{file}.." | |
AWS::S3::S3Object.store(file, open(file), WEBSITE_BUCKET_NAME) | |
puts "done!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! Appreciated!