Class: Backup::Storage::Everbox

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/storage/everbox.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, storage_id = nil, &block) ⇒ Everbox

Returns a new instance of Everbox.



11
12
13
14
15
16
17
# File 'lib/backup/storage/everbox.rb', line 11

def initialize(model, storage_id = nil, &block)
  super(model, storage_id)

  @path ||= 'backups'

  instance_eval(&block) if block_given?
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



9
10
11
# File 'lib/backup/storage/everbox.rb', line 9

def path
  @path
end

#secretObject

Returns the value of attribute secret.



8
9
10
# File 'lib/backup/storage/everbox.rb', line 8

def secret
  @secret
end

#tokenObject

Returns the value of attribute token.



8
9
10
# File 'lib/backup/storage/everbox.rb', line 8

def token
  @token
end

Instance Method Details

#transfer!Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/backup/storage/everbox.rb', line 19

def transfer!
  remote_path = remote_path_for(@package)

  connection = Backup::Connection::Everbox.new(token, secret)

  files_to_transfer_for(@package) do |local_file, remote_file|
    Logger.message "#{storage_name} started transferring " +
        "'#{ local_file }'."
    connection.session.upload(
      File.join(local_path, local_file),
      File.join(remote_path, remote_file),
      :mode => :dropbox
      )


    #File.open(File.join(local_path, local_file), 'r') do |file|
    #  connection.put_object(
    #    bucket, File.join(remote_path, remote_file), file
    #  )
    #end
  end
end