Class: Vos::Drivers::S3
- Inherits:
-
Object
- Object
- Vos::Drivers::S3
- Includes:
- S3VfsStorage
- Defined in:
- lib/vos/drivers/s3.rb
Instance Attribute Summary collapse
-
#box ⇒ Object
Returns the value of attribute box.
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #_clear ⇒ Object
- #close ⇒ Object
-
#initialize(options = {}) ⇒ S3
constructor
A new instance of S3.
-
#inspect ⇒ Object
(also: #to_s)
Miscellaneous.
-
#open(&block) ⇒ Object
Establishing SSH channel.
Methods included from S3VfsStorage
#attributes, #create_dir, #delete_dir, #delete_file, #each_entry, #local?, #read_file, #set_attributes, #tmp, #write_file
Constructor Details
#initialize(options = {}) ⇒ S3
Returns a new instance of S3.
10 11 12 13 14 15 |
# File 'lib/vos/drivers/s3.rb', line 10 def initialize = {} = .clone @bucket_name = .delete(:bucket) || raise("S3 bucket not provided!") @acl = .delete(:acl) || :public_read @options = end |
Instance Attribute Details
#box ⇒ Object
Returns the value of attribute box.
7 8 9 |
# File 'lib/vos/drivers/s3.rb', line 7 def box @box end |
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
8 9 10 |
# File 'lib/vos/drivers/s3.rb', line 8 def bucket @bucket end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
8 9 10 |
# File 'lib/vos/drivers/s3.rb', line 8 def connection @connection end |
Instance Method Details
#_clear ⇒ Object
55 56 57 |
# File 'lib/vos/drivers/s3.rb', line 55 def _clear bucket.objects.each{|o| o.delete} end |
#close ⇒ Object
41 |
# File 'lib/vos/drivers/s3.rb', line 41 def close; end |
#inspect ⇒ Object Also known as: to_s
Miscellaneous
52 |
# File 'lib/vos/drivers/s3.rb', line 52 def inspect; "https://#{bucket_name}.s3.amazonaws.com" end |
#open(&block) ⇒ Object
Establishing SSH channel
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vos/drivers/s3.rb', line 21 def open &block if block if connection block.call self else begin open block.call self ensure close end end else unless connection @connection = ::AWS::S3.new self..clone @bucket = @connection.buckets[bucket_name] end end end |