Skip to content

Instantly share code, notes, and snippets.

@torkale
Last active August 29, 2015 14:15
Show Gist options
  • Save torkale/25b2918a9584d4e7559e to your computer and use it in GitHub Desktop.
Save torkale/25b2918a9584d4e7559e to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'aws'
require 'json'
AWS.config(
:access_key_id => '<access key>',
:secret_access_key => '<secret key>',
)
s3 = AWS.regions['us-east-1'].s3
bucket_name = "<bucket name>"
bucket = s3.buckets[bucket_name]
unless bucket.exists?
bucket = s3.buckets.create(bucket_name)
end
obj = bucket.objects['<folder>']
# for public serving of files + caching
File.open(<file path>, 'r') do |f|
obj.write(f, {
:content_type => '<content type>',
:cache_control => 'public,max-age=86399,s-maxage=120'
})
obj.acl= :public_read
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment