Created
July 1, 2009 09:34
-
-
Save pierrevalade/138705 to your computer and use it in GitHub Desktop.
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
require 'rubygems' | |
require 'right_aws' | |
i = 1 | |
path = '/Users/pierre/Desktop/items/pictures/**/*' | |
s3 = RightAws::S3.new(access_key, secret_key) | |
s3_bucket = s3.bucket('twistip', false, 'public-read') | |
headers = {'Content-type' => 'image/jpeg', 'Expires' => "Thu, 01 Jul 2019 08:37:04 GMT", 'Cache-Control' => 'public, max-age=315360000'} | |
Dir.glob(path).each do |f| | |
next if File.directory?(f) | |
p = "items/pictures/#{f[path.length, f.length]}" | |
key = s3_bucket.key(p) | |
unless key.exists? | |
puts("#{i} - saving #{p} ...") | |
key.data = File.read(f) | |
key.put(nil, 'public-read', headers) | |
puts("#{i} - saved #{p}") | |
else | |
puts("#{i} - skipped #{p}") | |
end | |
i += 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment