Sha256: 522edc437365b3460da6ff0f15ab56ce57828cb82d7da0975bd790be56474360

Contents?: true

Size: 1.32 KB

Versions: 7

Compression:

Stored size: 1.32 KB

Contents

module Backup
  module Connection
    class S3 < Backup::Connection::Base
      
      def initialize(options = {})
        options.symbolize_keys!
        options[:s3].symbolize_keys!
        super(options)
      end
      
      # Establishes a connection with Amazon S3 using the credentials provided by the user
      def connect
        AWS::S3::Base.establish_connection!(
          :access_key_id     => options[:s3][:access_key_id], 
          :secret_access_key => options[:s3][:secret_access_key]
        )
      end
      
      # Wrapper for the Service object
      def service
        AWS::S3::Service
      end
      
      # Wrapper for the Bucket object
      def bucket
        AWS::S3::Bucket
      end
      
      # Wrapper for the Object object
      def object
        AWS::S3::S3Object
      end
      
      # Initializes the file transfer to Amazon S3
      # This can only run after a connection has been made using the #connect method 
      def transfer
        object.store(
          options[:backup_file],
          open(File.join(options[:backup_path], options[:backup_file])),
          options[:s3][:bucket] )
      end
      
      # Destroys file from a bucket on Amazon S3
      def destroy(backup_file, bucket)
        object.delete(
          backup_file,
          bucket )
      end
      
    end
  end 
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
backup-1.3.4 lib/backup/connection/s3.rb
backup-1.3.3 lib/backup/connection/s3.rb
backup-1.3.2 lib/backup/connection/s3.rb
backup-1.3.1 lib/backup/connection/s3.rb
backup-1.3.0 lib/backup/connection/s3.rb
backup-1.2.2 lib/backup/connection/s3.rb
backup-1.2.1 lib/backup/connection/s3.rb