End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Net::FTP#storlines
storlines(cmd, file) { |line| ... }
lib/net/ftp.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/net/ftp.rb, line 733
def storlines(cmd, file) # :yield: line
synchronize do
with_binary(false) do
begin
conn = transfercmd(cmd)
while buf = file.gets
if buf[-2, 2] != CRLF
buf = buf.chomp + CRLF
end
conn.write(buf)
yield(buf) if block_given?
end
conn.shutdown(Socket::SHUT_WR) rescue nil
conn.read_timeout = 1
conn.read rescue nil
ensure
conn.close if conn
end
voidresp
end
end
rescue Errno::EPIPE
# EPIPE, in this case, means that the data connection was unexpectedly
# terminated. Rather than just raising EPIPE to the caller, check the
# response on the control connection. If getresp doesn't raise a more
# appropriate exception, re-raise the original exception.
getresp
raise
end
Puts the connection into ASCII (text) mode, issues the given server-side command (such as “STOR myfile”), and sends the contents of the file named file to the server, one line at a time. If the optional block is given, it also passes it the lines.