Created
April 17, 2013 18:06
-
-
Save dannguyen/5406431 to your computer and use it in GitHub Desktop.
Using Ruby AWS-SDK to write an object to S3 and set its ACL
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/ruby | |
require 'rubygems' | |
require 'aws-sdk' | |
#creates an interface object to AWS S3 | |
AWS.config( :access_key_id => '' , :secret_access_key => '' ) | |
#creates an interface to the S3 | |
s3interface = AWS::S3.new | |
object_key = 'testobject.txt' | |
object_data = 'Hello, World!' | |
#print redirector_object.inspect | |
bucket = s3interface.buckets['mydomain.com'] | |
object = bucket.objects[object_key] | |
object.write('Hello World!') | |
object.acl=(:public_read) | |
object.metadata['website-redirect-location'] = 'http://mydomain.com/file.txt' | |
# via: https://forums.aws.amazon.com/thread.jspa?messageID=399096 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment