storlines(cmd, file)
public
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.
Show source
def storlines(cmd, file)
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_given?
end
conn.close
voidresp
end
end
rescue Errno::EPIPE
getresp
raise
end