Skip to content

Instantly share code, notes, and snippets.

@seratch
Created October 11, 2012 10:19
Show Gist options
  • Save seratch/3871455 to your computer and use it in GitHub Desktop.
Save seratch/3871455 to your computer and use it in GitHub Desktop.
CDPStudyGroup S3 example
access_key_id: xxx
secret_access_key: yyy
#!/usr/bin/env ruby
require 'yaml'
require 'aws-sdk'
config_file = File.join(File.dirname(__FILE__),"config.yml")
config = YAML.load(File.read(config_file))
AWS.config(config)
s3 = AWS::S3.new
bucket = s3.buckets[:seratchtokyoexample]
foo = bucket.objects["foo"]
# upload content
foo.write(Time.now.to_s)
# make public
foo.acl.change do |acl|
acl.grant(:read).to(:group_uri => 'http://acs.amazonaws.com/groups/global/AllUsers')
end
# https://s3-ap-northeast-1.amazonaws.com/seratchtokyoexample/foo
@seratch
Copy link
Author

seratch commented Oct 11, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment