Skip to content

Instantly share code, notes, and snippets.

@arches
Created February 27, 2014 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arches/9256285 to your computer and use it in GitHub Desktop.
Save arches/9256285 to your computer and use it in GitHub Desktop.
batch upload to s3
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