Last active
August 29, 2015 14:15
-
-
Save torkale/25b2918a9584d4e7559e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/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