Type:
Class
Constants:
MDTM_REGEXP : /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/

This class implements the File Transfer Protocol. If you have used a command-line FTP program, and are familiar with the commands, you will be able to use this class easily. Some extra features are included to take advantage of Ruby's style and strengths.

Example

require 'net/ftp'

Example 1

ftp = Net::FTP.new('example.com')
ftp.login
files = ftp.chdir('pub/lang/ruby/contrib')
files = ftp.list('n*')
ftp.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024)
ftp.close

Example 2

Net::FTP.open('example.com') do |ftp|
  ftp.login
  files = ftp.chdir('pub/lang/ruby/contrib')
  files = ftp.list('n*')
  ftp.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024)
end

Major Methods

The following are the methods most likely to be useful to users:

gettextfile

gettextfile(remotefile, localfile = File.basename(remotefile)) Instance Public methods

2015-04-20 14:03:24
nlst

nlst(dir = nil) Instance Public methods Returns an array of filenames in the

2015-04-20 14:36:09
mdtm

mdtm(filename) Instance Public methods Issues the MDTM command. TODO: more

2015-04-20 14:21:06
quit

quit() Instance Public methods Exits the

2015-04-20 14:55:04
put

put(localfile, remotefile = File.basename(localfile), blocksize = DEFAULT_BLOCKSIZE, &block) Instance Public

2015-04-20 14:40:24
storlines

storlines(cmd, file) Instance Public methods Puts the connection into ASCII

2015-04-20 15:42:12
retrlines

retrlines(cmd) Instance Public methods Puts the connection into ASCII (text)

2015-04-20 15:09:17
mkdir

mkdir(dirname) Instance Public methods Creates a remote directory.

2015-04-20 14:27:22
rmdir

rmdir(dirname) Instance Public methods Removes a remote directory.

2015-04-20 15:15:52
puttextfile

puttextfile(localfile, remotefile = File.basename(localfile)) Instance Public methods

2015-04-20 14:49:55