Class: Aws::S3Generator
Overview
Aws::S3Generator and Aws::S3Generator::Bucket methods:
s3g = Aws::S3Generator.new('1...2', 'nx...Y6') #=> #<Aws::S3Generator:0xb7b5cc94>
# List all buckets(method 'GET'):
buckets_list = s3g.buckets #=> 'https://s3.amazonaws.com:443/?Signature=Y...D&Expires=1180941864&AWSAccessKeyId=1...2'
# Create bucket link (method 'PUT'):
bucket = s3g.bucket('my_awesome_bucket') #=> #<Aws::S3Generator::Bucket:0xb7bcbda8>
link_to_create = bucket.create_link(1.hour) #=> https://s3.amazonaws.com:443/my_awesome_bucket?Signature=4...D&Expires=1180942132&AWSAccessKeyId=1...2
# ... or:
bucket = Aws::S3Generator::Bucket.create(s3g, 'my_awesome_bucket') #=> #<Aws::S3Generator::Bucket:0xb7bcbda8>
link_to_create = bucket.create_link(1.hour) #=> https://s3.amazonaws.com:443/my_awesome_bucket?Signature=4...D&Expires=1180942132&AWSAccessKeyId=1...2
# ... or:
bucket = Aws::S3Generator::Bucket.new(s3g, 'my_awesome_bucket') #=> #<Aws::S3Generator::Bucket:0xb7bcbda8>
link_to_create = bucket.create_link(1.hour) #=> https://s3.amazonaws.com:443/my_awesome_bucket?Signature=4...D&Expires=1180942132&AWSAccessKeyId=1...2
# List bucket(method 'GET'):
bucket.keys(1.day) #=> https://s3.amazonaws.com:443/my_awesome_bucket?Signature=i...D&Expires=1180942620&AWSAccessKeyId=1...2
# Create/put key (method 'PUT'):
bucket.put('my_cool_key') #=> https://s3.amazonaws.com:443/my_awesome_bucket/my_cool_key?Signature=q...D&Expires=1180943094&AWSAccessKeyId=1...2
# Get key data (method 'GET'):
bucket.get('logs/today/1.log', 1.hour) #=> https://s3.amazonaws.com:443/my_awesome_bucket/my_cool_key?Signature=h...M%3D&Expires=1180820032&AWSAccessKeyId=1...2
# Delete bucket (method 'DELETE'):
bucket.delete(2.hour) #=> https://s3.amazonaws.com:443/my_awesome_bucket/logs%2Ftoday%2F1.log?Signature=4...D&Expires=1180820032&AWSAccessKeyId=1...2
Aws::S3Generator::Key methods:
# Create Key instance:
key = Aws::S3Generator::Key.new(bicket, 'my_cool_key') #=> #<Aws::S3Generator::Key:0xb7b7394c>
# Put key data (method 'PUT'):
key.put #=> https://s3.amazonaws.com:443/my_awesome_bucket/my_cool_key?Signature=2...D&Expires=1180943302&AWSAccessKeyId=1...2
# Get key data (method 'GET'):
key.get #=> https://s3.amazonaws.com:443/my_awesome_bucket/my_cool_key?Signature=a...D&Expires=1180820032&AWSAccessKeyId=1...2
# Head key (method 'HEAD'):
key.head #=> https://s3.amazonaws.com:443/my_awesome_bucket/my_cool_key?Signature=b...D&Expires=1180820032&AWSAccessKeyId=1...2
# Delete key (method 'DELETE'):
key.delete #=> https://s3.amazonaws.com:443/my_awesome_bucket/my_cool_key?Signature=x...D&Expires=1180820032&AWSAccessKeyId=1...2
Defined Under Namespace
Instance Attribute Summary collapse
-
#interface ⇒ Object
readonly
Returns the value of attribute interface.
Instance Method Summary collapse
-
#bucket(name, expires = nil, headers = {}) ⇒ Object
Create new S3LinkBucket instance and generate link to create it at S3.
-
#buckets(expires = nil, headers = {}) ⇒ Object
Generate link to list all buckets.
-
#initialize(aws_access_key_id, aws_secret_access_key, params = {}) ⇒ S3Generator
constructor
A new instance of S3Generator.
Constructor Details
#initialize(aws_access_key_id, aws_secret_access_key, params = {}) ⇒ S3Generator
Returns a new instance of S3Generator.
938 939 940 |
# File 'lib/s3/right_s3.rb', line 938 def initialize(aws_access_key_id, aws_secret_access_key, params={}) @interface = S3Interface.new(aws_access_key_id, aws_secret_access_key, params) end |
Instance Attribute Details
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
936 937 938 |
# File 'lib/s3/right_s3.rb', line 936 def interface @interface end |
Instance Method Details
#bucket(name, expires = nil, headers = {}) ⇒ Object
Create new S3LinkBucket instance and generate link to create it at S3.
bucket= s3.bucket('my_owesome_bucket')
954 955 956 |
# File 'lib/s3/right_s3.rb', line 954 def bucket(name, expires=nil, headers={}) Bucket.create(self, name.to_s) end |
#buckets(expires = nil, headers = {}) ⇒ Object
Generate link to list all buckets
s3.buckets(1.hour)
946 947 948 |
# File 'lib/s3/right_s3.rb', line 946 def buckets(expires=nil, headers={}) @interface.list_all_my_buckets_link(expires, headers) end |