Skip to content

Instantly share code, notes, and snippets.

@ivanoats
Created February 5, 2013 05:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanoats/4712421 to your computer and use it in GitHub Desktop.
Save ivanoats/4712421 to your computer and use it in GitHub Desktop.
Upload files to S3
#!/usr/bin/ruby
require 'rubygems'
require 'fog'
s3_access_key_id = "my_access_key_id"
s3_secret_access_key = "my_secret_access_key"
storage = Fog::Storage.new({:provider => 'AWS', :aws_access_key_id => s3_access_key_id, :aws_secret_access_key => s3_secret_access_key })
directory = storage.directories.get("bucket-name-that-I-created-already-via-aws-console")
ARGV.each do |filename|
unless directory.files.head(filename)
file = directory.files.create(
:key => filename,
:body => File.open(filename),
:public => true
)
end
file.save
end
@ivanoats
Copy link
Author

ivanoats commented Feb 5, 2013

For you:
adjust ruby path in line 1
chmod +x fogit.rb
(sudo) gem install fog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment