[英]How to connect to FTPS using Ruby 2.3?
From what I see latest Ruby that supported FTPS was 1.8.从我看到的支持 FTPS 的最新 Ruby 是 1.8。 I found some gems that can connect to FTPS, but they were no updated in several years.我发现了一些可以连接到 FTPS 的 gem,但它们已经好几年没有更新了。 Did anyone had to do this recently?最近有人必须这样做吗? What gem did you use?你用的什么宝石?
And for FTPS you can use net/sftp https://github.com/net-ssh/net-sftp对于 FTPS,您可以使用 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.