Method: FileTransfer::Ftp#move

Defined in:
lib/file_transfer/ftp.rb

#move(from_path, to_path) ⇒ Object Also known as: rename

Moves file from source to destination on FTP server

Parameters:

  • from_path (String)

    remote source path

  • to_path (String)

    remote destination path



58
59
60
61
62
63
64
65
# File 'lib/file_transfer/ftp.rb', line 58

def move(from_path, to_path)
  from_path = split_path(from_path)
  to_path = split_path(to_path)
  open_connection do
    ftp.chdir from_path[:file_path]
    ftp.rename from_path[:file_name], "#{to_path[:file_path]}/#{to_path[:file_name]}" if exist?("#{from_path[:file_name]}/#{from_path[:file_path]}")
  end
end