Last active
December 18, 2015 15:19
-
-
Save stefan-mees/5803315 to your computer and use it in GitHub Desktop.
aws s3 add expire / cache header to existing objects
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
AWS.config({ | |
:access_key_id => 'xxxxx', | |
:secret_access_key => 'xxxxx', | |
}) | |
bucket_name = 'xxxxx' | |
s3 = AWS::S3.new() | |
bucket = s3.buckets[bucket_name] | |
File.open('/tmp/listofkeys.txt').lines.each_with_index do |line,index| | |
key = line.strip | |
object = bucket.objects[key] | |
object.copy_to(key, :metadata => object.metadata.to_h, :content_type => object.content_type, :acl => :public_read, :expires=>"Thu, 31 Dec 2037 23:55:55 GMT", :cache_control=>"max-age=31556926") | |
p "progress: #{index}" if index%100==0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment