From what I see latest Ruby that supported FTPS was 1.8. I found some gems that can connect to FTPS, but they were no updated in several years. Did anyone had to do this recently? What gem did you use?
You can simply use net/ftp
standard library.
ftp = Net::FTP.new('cdimage.debian.org')
ftp.login
ftp.list
Or login to protected ftp:
ftp.login('username', 'password')
And for FTPS you can use net/sftp https://github.com/net-ssh/net-sftp
example of code :
require 'net/sftp'
Net::SFTP.start('host', 'username', :password => 'password') do |sftp|
# upload a file or directory to the remote host
sftp.upload!("/path/to/local", "/path/to/remote")
# download a file or directory from the remote host
sftp.download!("/path/to/remote", "/path/to/local")
# grab data off the remote host directly to a buffer
data = sftp.download!("/path/to/remote")
# open and write to a pseudo-IO for a remote file
sftp.file.open("/path/to/remote", "w") do |f|
f.puts "Hello, world!\n"
end
# open and read from a pseudo-IO for a remote file
sftp.file.open("/path/to/remote", "r") do |f|
puts f.gets
end
# create a directory
sftp.mkdir! "/path/to/directory"
# list the entries in a directory
sftp.dir.foreach("/path/to/directory") do |entry|
puts entry.longname
end
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.