Skip to content

Instantly share code, notes, and snippets.

@shoken0x
Created May 20, 2014 13:53
Show Gist options
  • Save shoken0x/e7fc37b2e0fecba48d31 to your computer and use it in GitHub Desktop.
Save shoken0x/e7fc37b2e0fecba48d31 to your computer and use it in GitHub Desktop.
S3の既存データにcache_controlを追加するスクリプト
require 'aws-sdk'
ACCESS_KEY_ID = 'xxxx'
SECRET_ACCESS_KEY = 'xxxx'
BUKETS = 'xxxx'
s3 = AWS::S3.new(
access_key_id: ACCESS_KEY_ID,
secret_access_key: SECRET_ACCESS_KEY)
bucket = s3.buckets[BUKETS]
one_year_in_seconds = 365 * 24 * 60 * 60
o = bucket.objects[ARGV[0]]
o.copy_to o.key, cache_control: "public, max-age=#{one_year_in_seconds}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment