Created
January 19, 2013 14:08
-
-
Save t11a/4572838 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
require 'aws-sdk' | |
AWS.config( | |
:access_key_id => 'your_access_key_id', | |
:secret_access_key => 'your_secret_access_key', | |
:s3_endpoint => 's3-ap-northeast-1.amazonaws.com' # see http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region | |
) | |
s3 = AWS::S3.new | |
bucket_name = 'your_bucket/path/to' | |
bucket = s3.buckets[bucket_name] | |
path_to = '/path/to' | |
upload_files = ['file1','file2'] | |
uploaded_files = upload_files.map do |file| | |
file = path_to + "/" + file | |
basename = File.basename(file) | |
obj = bucket.objects[basename] | |
res = obj.write(:file => file, :acl => :private) | |
res.key | |
end | |
puts "S3 Upload Success:#{uploaded_files.to_s}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment