Skip to content

Instantly share code, notes, and snippets.

@bruchu
Last active June 14, 2016 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bruchu/8230184 to your computer and use it in GitHub Desktop.
Save bruchu/8230184 to your computer and use it in GitHub Desktop.
change s3 content-type using aws ruby sdk
bash:
export AWS_ACCESS_KEY_ID='...'
export AWS_SECRET_ACCESS_KEY='...'
export AWS_REGION='us-east-1'
irb or ruby script:
require 'aws-sdk'
s3 = AWS::S3.new
bucket_name = 'bucket-name'
# a copy needs to be done to change the content-type
s3.buckets[bucket_name].objects.each do |object|
k = object.key
s3.buckets[bucket_name].objects[k].copy_from(k, :content_type => 'text/html')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment