Class: Backup::Connection::S3
- Inherits:
-
Object
- Object
- Backup::Connection::S3
- Defined in:
- lib/backup/connection/s3.rb
Instance Attribute Summary collapse
-
#access_key_id ⇒ Object
Returns the value of attribute access_key_id.
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#final_file ⇒ Object
Returns the value of attribute final_file.
-
#procedure ⇒ Object
Returns the value of attribute procedure.
-
#s3_bucket ⇒ Object
Returns the value of attribute s3_bucket.
-
#secret_access_key ⇒ Object
Returns the value of attribute secret_access_key.
-
#tmp_path ⇒ Object
Returns the value of attribute tmp_path.
-
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
Instance Method Summary collapse
-
#bucket ⇒ Object
Wrapper for the Bucket object.
-
#connect ⇒ Object
Establishes a connection with Amazon S3 using the credentials provided by the user.
-
#destroy(file, bucket) ⇒ Object
Destroys file from a bucket on Amazon S3.
-
#initialize(adapter = false) ⇒ S3
constructor
Initializes the S3 connection, setting the values using the S3 adapter.
-
#object ⇒ Object
Wrapper for the Object object.
-
#service ⇒ Object
Wrapper for the Service object.
-
#static_initialize(procedure) ⇒ Object
Sets values from a procedure, rather than from the adapter object.
-
#store ⇒ Object
Initializes the file transfer to Amazon S3 This can only run after a connection has been made using the #connect method.
Constructor Details
#initialize(adapter = false) ⇒ S3
Initializes the S3 connection, setting the values using the S3 adapter
8 9 10 11 12 13 14 15 16 |
# File 'lib/backup/connection/s3.rb', line 8 def initialize(adapter = false) if adapter self.adapter = adapter self.procedure = adapter.procedure self.final_file = adapter.final_file self.tmp_path = adapter.tmp_path.gsub('\ ', ' ') load_storage_configuration_attributes end end |
Instance Attribute Details
#access_key_id ⇒ Object
Returns the value of attribute access_key_id.
5 6 7 |
# File 'lib/backup/connection/s3.rb', line 5 def access_key_id @access_key_id end |
#adapter ⇒ Object
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/backup/connection/s3.rb', line 5 def adapter @adapter end |
#final_file ⇒ Object
Returns the value of attribute final_file.
5 6 7 |
# File 'lib/backup/connection/s3.rb', line 5 def final_file @final_file end |
#procedure ⇒ Object
Returns the value of attribute procedure.
5 6 7 |
# File 'lib/backup/connection/s3.rb', line 5 def procedure @procedure end |
#s3_bucket ⇒ Object
Returns the value of attribute s3_bucket.
5 6 7 |
# File 'lib/backup/connection/s3.rb', line 5 def s3_bucket @s3_bucket end |
#secret_access_key ⇒ Object
Returns the value of attribute secret_access_key.
5 6 7 |
# File 'lib/backup/connection/s3.rb', line 5 def secret_access_key @secret_access_key end |
#tmp_path ⇒ Object
Returns the value of attribute tmp_path.
5 6 7 |
# File 'lib/backup/connection/s3.rb', line 5 def tmp_path @tmp_path end |
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
5 6 7 |
# File 'lib/backup/connection/s3.rb', line 5 def use_ssl @use_ssl end |
Instance Method Details
#bucket ⇒ Object
Wrapper for the Bucket object
39 40 41 |
# File 'lib/backup/connection/s3.rb', line 39 def bucket AWS::S3::Bucket end |
#connect ⇒ Object
Establishes a connection with Amazon S3 using the credentials provided by the user
25 26 27 28 29 30 31 |
# File 'lib/backup/connection/s3.rb', line 25 def connect AWS::S3::Base.establish_connection!( :access_key_id => access_key_id, :secret_access_key => secret_access_key, :use_ssl => use_ssl ) end |
#destroy(file, bucket) ⇒ Object
Destroys file from a bucket on Amazon S3
59 60 61 62 63 |
# File 'lib/backup/connection/s3.rb', line 59 def destroy(file, bucket) object.delete( file, bucket ) end |
#object ⇒ Object
Wrapper for the Object object
44 45 46 |
# File 'lib/backup/connection/s3.rb', line 44 def object AWS::S3::S3Object end |
#service ⇒ Object
Wrapper for the Service object
34 35 36 |
# File 'lib/backup/connection/s3.rb', line 34 def service AWS::S3::Service end |
#static_initialize(procedure) ⇒ Object
Sets values from a procedure, rather than from the adapter object
19 20 21 22 |
# File 'lib/backup/connection/s3.rb', line 19 def static_initialize(procedure) self.procedure = procedure load_storage_configuration_attributes(true) end |
#store ⇒ Object
Initializes the file transfer to Amazon S3 This can only run after a connection has been made using the #connect method
50 51 52 53 54 55 56 |
# File 'lib/backup/connection/s3.rb', line 50 def store puts "Storing \"#{final_file}\" to bucket \"#{s3_bucket}\" on Amazon S3." object.store( final_file, open(File.join(tmp_path, final_file)), s3_bucket ) end |