Skip to content

Instantly share code, notes, and snippets.

@thechrisoshow
Created June 5, 2011 13:03
Show Gist options
  • Save thechrisoshow/1008942 to your computer and use it in GitHub Desktop.
Save thechrisoshow/1008942 to your computer and use it in GitHub Desktop.
This script uploads files to a S3 bucket
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
@kylemclaren
Copy link

Nice! Appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment