Created
November 15, 2011 01:23
-
-
Save wlrs/1365811 to your computer and use it in GitHub Desktop.
Set far future cache control for existing files in an s3 bucket
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 'aws/s3' | |
AWS::S3::Base.establish_connection!( | |
:access_key_id => '', | |
:secret_access_key => '' | |
) | |
bucket = AWS::S3::Bucket.find('my_bucket') | |
objects = bucket.objects | |
size = objects.size | |
objects.each_with_index do |file, index| | |
path = file.path | |
print "#{index + 1}/#{size} #{path} ... " | |
file.cache_control = 'max-age=315360000' | |
file.save({:access => :public_read}) | |
puts "done." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI, this appears to download each file locally, then upload it?