I'm trying to make a script in Ruby that can uploads a local file to a ftp server using a sftp connection.
The script establishes a connection to the server and creates the file just fine. The problem is that the file it not uploaded correctly. The filesize continues to be 0 bytes.
Here is the script:
require 'net/sftp'
Net::SFTP.start("HOST", 'USERNAME', :password => 'PASSWORD', :verbose => Logger::DEBUG) do |sftp|
sftp.upload!("/LOCAL/PATH/TO/FILE", "/REMOTE/PATH/TO/FILE")
end
When I am using Filezilla it works without any problems.
I am currently using the Net/sftp gem - Net/sftp - github site
I have opened port 21 and 22 on the server and given read/write permission to the user.
Am I missing something? I don't see any errors. Please tell me if I can provide you with any other information that might help you answering my question.