Created
February 27, 2014 18:39
-
-
Save arches/9256285 to your computer and use it in GitHub Desktop.
batch upload to s3
This file contains hidden or 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' | |
local_file = ARGV[0] | |
guid = ARGV[1] | |
bucket = ARGV[2] | |
mime_type = ARGV[3] | |
AWS::S3::Base.establish_connection!( | |
:access_key_id => 'AKJAFLWEAJFLAKJ', | |
:secret_access_key => 'pfejfpEFjwfwfJ+wefwf/fiejwLwfj' | |
) | |
base_name = File.basename(local_file) | |
puts "Uploading #{local_file} as '#{base_name}' to '#{bucket}'" | |
AWS::S3::S3Object.store( | |
"/photos/#{guid}/original/#{base_name}", | |
File.open(local_file), | |
bucket, | |
content_type: mime_type | |
) | |
puts "Uploaded!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment