I am using Net :: SFTP to upload a file to the 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 downloads a null byte file with the correct file name. 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 contents of the file do not load, I just get the file with a zero byte. I can’t find anything on Google. Does anyone know how to fix this problem?
FYI, I can upload a file using WinSCP.
source
share