Method: Edploy::FileHandling.upload_file

Defined in:
lib/edployscripts/file_handling.rb

.upload_file(file, tmp_path, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/edployscripts/file_handling.rb', line 6

def upload_file(file, tmp_path, &block)
  if File.exists?(file)
    random_string = "#{Time.now.to_i}"
    tmp_file = "#{tmp_path}/#{random_string}-#{File.basename(file)}"
    commands << "mkdir -p #{File.dirname(tmp_file)}"
    put File.read(file), tmp_file, :mode => 0644
    yield(tmp_file)
  end
end