Class | RightAws::S3::Key |
In: |
lib/s3/right_s3.rb
|
Parent: | Object |
bucket | [R] | |
data | [W] | |
e_tag | [R] | |
headers | [RW] | |
last_modified | [R] | |
meta_headers | [RW] | |
name | [R] | |
owner | [R] | |
size | [R] | |
storage_class | [R] |
Create a new Key instance, but do not create the actual key. In normal use this method should not be called directly. Use RightAws::S3::Key.create or bucket.key() instead.
Create an object copy. Returns a destination RightAws::S3::Key instance.
# Key instance as destination key1 = RightAws::S3::Key.create(bucket, 'logs/today/1.log') #=> #<RightAws::S3::Key:0xb7b1e240 ... > key2 = RightAws::S3::Key.create(bucket, 'logs/today/2.log') #=> #<RightAws::S3::Key:0xb7b5e240 ... > key1.put('Olala!') #=> true key1.copy(key2) #=> #<RightAws::S3::Key:0xb7b5e240 ... > key1.exists? #=> true key2.exists? #=> true puts key2.data #=> 'Olala!' # String as destination key = RightAws::S3::Key.create(bucket, 'logs/today/777.log') #=> #<RightAws::S3::Key:0xb7b1e240 ... > key.put('Olala!') #=> true new_key = key.copy('logs/today/888.log') #=> #<RightAws::S3::Key:0xb7b5e240 ... > key.exists? #=> true new_key.exists? #=> true
Check for existence of the key in the given bucket. Returns true or false.
key = RightAws::S3::Key.create(bucket,'logs/today/1.log') key.exists? #=> false key.put('Woohoo!') #=> true key.exists? #=> true
Return the full S3 path to this key (bucket/key).
key.full_name #=> 'my_awesome_bucket/cool_key'
Updates headers and meta-headers from S3. Returns true.
key.meta_headers #=> {"family"=>"qwerty"} key.head #=> true key.meta_headers #=> {"family"=>"qwerty", "name"=>"asdfg"}
Move an object to other location. Returns a destination RightAws::S3::Key instance.
# Key instance as destination key1 = RightAws::S3::Key.create(bucket, 'logs/today/1.log') #=> #<RightAws::S3::Key:0xb7b1e240 ... > key2 = RightAws::S3::Key.create(bucket, 'logs/today/2.log') #=> #<RightAws::S3::Key:0xb7b5e240 ... > key1.put('Olala!') #=> true key1.move(key2) #=> #<RightAws::S3::Key:0xb7b5e240 ... > key1.exists? #=> false key2.exists? #=> true puts key2.data #=> 'Olala!' # String as destination key = RightAws::S3::Key.create(bucket, 'logs/today/777.log') #=> #<RightAws::S3::Key:0xb7b1e240 ... > key.put('Olala!') #=> true new_key = key.move('logs/today/888.log') #=> #<RightAws::S3::Key:0xb7b5e240 ... > key.exists? #=> false new_key.exists? #=> true
Return a public link to a key.
key.public_link #=> 'https://s3.amazonaws.com:443/my_awesome_bucket/cool_key'
Retrieve key info from bucket and update attributes. Refresh meta-headers (by calling head method) if head is set. Returns true if the key exists in bucket and false otherwise.
key = RightAws::S3::Key.create(bucket, 'logs/today/1.log') key.e_tag #=> nil key.meta_headers #=> {} key.refresh #=> true key.e_tag #=> '12345678901234567890bf11094484b6' key.meta_headers #=> {"family"=>"qwerty", "name"=>"asdfg"}
Reload meta-headers only. Returns meta-headers hash.
key.reload_meta #=> {"family"=>"qwerty", "name"=>"asdfg"}
Rename an object. Returns new object name.
key = RightAws::S3::Key.create(bucket, 'logs/today/1.log') #=> #<RightAws::S3::Key:0xb7b1e240 ... > key.rename('logs/today/2.log') #=> 'logs/today/2.log' puts key.name #=> 'logs/today/2.log' key.exists? #=> true