Skip to content

Instantly share code, notes, and snippets.

@mikedemers
Created March 20, 2013 18:36
Show Gist options
  • Save mikedemers/5207257 to your computer and use it in GitHub Desktop.
Save mikedemers/5207257 to your computer and use it in GitHub Desktop.
Ruby script that sends a file to an S3 bucket
#!/usr/bin/env ruby
require 'rubygems'
require 'aws/s3'
bucket = ARGV[0].to_s.strip
filepath = ARGV[1].to_s.strip
filename = ARGV[2] ? ARGV[2].to_s.strip : File.basename(filepath)
AWS::S3::Base.establish_connection!(
:access_key_id => 'xxxxxxx',
:secret_access_key => 'xxxxxxx'
)
AWS::S3::S3Object.store(filename, open(filepath), bucket)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment