Class: Upload

Inherits:
Object
  • Object
show all
Defined in:
lib/db_time_machine/upload.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(f) ⇒ Upload

Returns a new instance of Upload.



5
6
7
8
9
# File 'lib/db_time_machine/upload.rb', line 5

def initialize(f)
  self.fog_connection      = DbTimeMachine.configuration.fog_connection
  self.fog_directory       = self.fog_connection.directories.get(DbTimeMachine.configuration.fog_dir)
  self.file                = f
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



3
4
5
# File 'lib/db_time_machine/upload.rb', line 3

def file
  @file
end

#fog_connectionObject

Returns the value of attribute fog_connection.



3
4
5
# File 'lib/db_time_machine/upload.rb', line 3

def fog_connection
  @fog_connection
end

#fog_directoryObject

Returns the value of attribute fog_directory.



3
4
5
# File 'lib/db_time_machine/upload.rb', line 3

def fog_directory
  @fog_directory
end

Instance Method Details

#startObject



11
12
13
14
15
16
17
18
19
# File 'lib/db_time_machine/upload.rb', line 11

def start
  puts "uploading data to fog directory"
  self.fog_directory.files.create(
    :key    => file.split('/').last,
    :body   => File.open(file),
    :public => false
  )
  puts "upload complate"
end