brock
11/7/2012 - 7:48 PM

This script uploads files to a S3 bucket

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