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.
# File lib/net/ftp.rb, line 528
def storlines(cmd, file, &block) # :yield: line
synchronize do
with_binary(false) do
conn = transfercmd(cmd)
loop do
buf = file.gets
break if buf == nil
if buf[-2, 2] != CRLF
buf = buf.chomp + CRLF
end
conn.write(buf)
yield(buf) if block
end
conn.close
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