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#putbinaryfile
putbinaryfile(localfile, remotefile = File.basename(localfile), blocksize = DEFAULT_BLOCKSIZE) { |data| ... }
lib/net/ftp.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/net/ftp.rb, line 844
def putbinaryfile(localfile, remotefile = File.basename(localfile),
blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
if @resume
begin
rest_offset = size(remotefile)
rescue Net::FTPPermError
rest_offset = nil
end
else
rest_offset = nil
end
f = File.open(localfile)
begin
f.binmode
if rest_offset
storbinary("APPE #{remotefile}", f, blocksize, rest_offset, &block)
else
storbinary("STOR #{remotefile}", f, blocksize, rest_offset, &block)
end
ensure
f.close
end
end
Transfers localfile to the server in binary mode, storing the result in remotefile. If a block is supplied, calls it, passing in the transmitted data in blocksize chunks.