Class: Beso::Connection::AWS
- Inherits:
-
Object
- Object
- Beso::Connection::AWS
- Defined in:
- lib/beso/connection.rb
Instance Method Summary collapse
- #get(filename) ⇒ Object
-
#initialize(options) ⇒ AWS
constructor
A new instance of AWS.
- #read(filename) ⇒ Object
- #write(filename, body) ⇒ Object
Constructor Details
#initialize(options) ⇒ AWS
Returns a new instance of AWS.
7 8 9 10 11 12 |
# File 'lib/beso/connection.rb', line 7 def initialize( ) @access_key = .delete( :access_key ) or raise MissingAccessKeyError @secret_key = .delete( :secret_key ) or raise MissingSecretKeyError @bucket_name = .delete( :bucket_name ) or raise MissingBucketNameError @aws_region = .delete( :aws_region ) end |
Instance Method Details
#get(filename) ⇒ Object
14 15 16 |
# File 'lib/beso/connection.rb', line 14 def get( filename ) bucket.files.get filename end |
#read(filename) ⇒ Object
18 19 20 |
# File 'lib/beso/connection.rb', line 18 def read( filename ) get( filename ).try( :body ) || '' end |
#write(filename, body) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/beso/connection.rb', line 22 def write( filename, body ) if file = get( filename ) file.body = body file.save else storage.put_object @bucket_name, filename, body, headers end end |