Class: RightAws::S3Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/s3/right_s3.rb

Overview

RightAws::S3Generator and RightAws::S3Generator::Bucket methods:

s3g = RightAws::S3Generator.new('1...2', 'nx...Y6') #=> #<RightAws::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')     #=> #<RightAws::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 = RightAws::S3Generator::Bucket.create(s3g, 'my_awesome_bucket') #=> #<RightAws::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 = RightAws::S3Generator::Bucket.new(s3g, 'my_awesome_bucket') #=> #<RightAws::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

RightAws::S3Generator::Key methods:

  # Create Key instance:  
key = RightAws::S3Generator::Key.new(bicket, 'my_cool_key') #=> #<RightAws::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

Classes: Bucket, Key

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aws_access_key_id, aws_secret_access_key, params = {}) ⇒ S3Generator

Returns a new instance of S3Generator.



998
999
1000
# File 'lib/s3/right_s3.rb', line 998

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

#interfaceObject (readonly)

Returns the value of attribute interface.



996
997
998
# File 'lib/s3/right_s3.rb', line 996

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')


1014
1015
1016
# File 'lib/s3/right_s3.rb', line 1014

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)


1006
1007
1008
# File 'lib/s3/right_s3.rb', line 1006

def buckets(expires=nil, headers={})
  @interface.list_all_my_buckets_link(expires, headers)
end