Created
February 5, 2013 05:28
-
-
Save ivanoats/4712421 to your computer and use it in GitHub Desktop.
Upload files to S3
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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For you:
adjust ruby path in line 1
chmod +x fogit.rb
(sudo) gem install fog