I'm using Net::SFTP to upload a file to a server. Here is the code:
uri = URI.parse('sftp://host.org')
io = StringIO.new(csv_string)
timeout 120 do
Net::SFTP.start(uri.host,ENV['SFTP_USER'],:password=>ENV['SFTP_PASS'],:port=>22) do |sftp|
sftp.upload(io, "/ftpguest/Medstro/" + file_name)
end
end
When I run the code, it successfully connects to the host and uploads a zero-byte file with the correct filename. Then it throws this exception:
lib/ruby/gems/2.3.0/gems/net-sftp-2.1.2/lib/net/sftp/session.rb:947:in `dispatch_request': no such request `403046400' (Net::SFTP::Exception)
The file contents aren't uploaded, I just get a zero-byte file. I can't find anything on Google. Does anyone know how to troubleshoot this?
FYI, I can upload the file fine using WinSCP.