Class: Aws::S3Generator::Key
- Inherits:
-
Object
- Object
- Aws::S3Generator::Key
- Defined in:
- lib/s3/s3.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#delete(expires = nil, headers = {}) ⇒ Object
Generate link to delete key.
-
#full_name(separator = '/') ⇒ Object
Return a full S# name (bucket/key).
-
#get(expires = nil, headers = {}) ⇒ Object
Generate link to GET key data.
-
#head(expires = nil, headers = {}) ⇒ Object
Generate link to head key.
-
#initialize(bucket, name, meta_headers = {}) ⇒ Key
constructor
A new instance of Key.
-
#public_link ⇒ Object
Return a public link to key.
-
#put(expires = nil, headers = {}) ⇒ Object
Generate link to PUT key data.
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
283 284 285 |
# File 'lib/s3/s3.rb', line 283 def bucket @bucket end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
283 284 285 |
# File 'lib/s3/s3.rb', line 283 def name @name end |
Instance Method Details
#delete(expires = nil, headers = {}) ⇒ Object
Generate link to delete key.
bucket.delete(2.hour) #=> https://s3.amazonaws.com:443/my_awesome_bucket/logs%2Ftoday%2F1.log?Signature=4...D&Expires=1180820032&AWSAccessKeyId=1...2
333 334 335 |
# File 'lib/s3/s3.rb', line 333 def delete(expires=nil, headers={}) @bucket.s3.interface.delete_link(@bucket.to_s, @name, expires, headers) end |
#full_name(separator = '/') ⇒ Object
Return a full S# name (bucket/key).
key.full_name #=> 'my_awesome_bucket/cool_key'
293 294 295 |
# File 'lib/s3/s3.rb', line 293 def full_name(separator='/') "#{@bucket.to_s}#{separator}#{@name}" end |
#get(expires = nil, headers = {}) ⇒ Object
Generate link to GET key data.
bucket.get('logs/today/1.log', 1.hour) #=> https://s3.amazonaws.com:443/my_awesome_bucket/logs%2Ftoday%2F1.log?Signature=h...M%3D&Expires=1180820032&AWSAccessKeyId=1...2
325 326 327 |
# File 'lib/s3/s3.rb', line 325 def get(expires=nil, headers={}) @bucket.s3.interface.get_link(@bucket.to_s, @name, expires, headers) end |
#head(expires = nil, headers = {}) ⇒ Object
Generate link to head key.
bucket.head(2.hour) #=> https://s3.amazonaws.com:443/my_awesome_bucket/logs%2Ftoday%2F1.log?Signature=4...D&Expires=1180820032&AWSAccessKeyId=1...2
341 342 343 |
# File 'lib/s3/s3.rb', line 341 def head(expires=nil, headers={}) @bucket.s3.interface.head_link(@bucket.to_s, @name, expires, headers) end |
#public_link ⇒ Object
Return a public link to key.
key.public_link #=> 'https://s3.amazonaws.com:443/my_awesome_bucket/cool_key'
301 302 303 304 |
# File 'lib/s3/s3.rb', line 301 def public_link params = @bucket.s3.interface.params "#{params[:protocol]}://#{params[:server]}:#{params[:port]}/#{full_name('/')}" end |
#put(expires = nil, headers = {}) ⇒ Object
Generate link to PUT key data.
puts bucket.put('logs/today/1.log', '123', 2.hour) #=> https://s3.amazonaws.com:443/my_awesome_bucket/logs%2Ftoday%2F1.log?Signature=B...D&Expires=1180820032&AWSAccessKeyId=1...2
317 318 319 |
# File 'lib/s3/s3.rb', line 317 def put(expires=nil, headers={}) @bucket.put(@name.to_s, @meta_headers, expires, headers) end |
#to_s ⇒ Object
285 286 287 |
# File 'lib/s3/s3.rb', line 285 def to_s @name end |