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:

login

login(user = "anonymous", passwd = nil, acct = nil) Instance Public methods Logs

2015-04-20 14:11:07
putbinaryfile

putbinaryfile(localfile, remotefile = File.basename(localfile), blocksize = DEFAULT_BLOCKSIZE) Instance Public methods

2015-04-20 14:46:42
get

get(remotefile, localfile = File.basename(remotefile), blocksize = DEFAULT_BLOCKSIZE) Instance Public methods

2015-04-20 13:43:17
puttextfile

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

2015-04-20 14:49:55
pwd

pwd() Instance Public methods Returns the current remote directory.

2015-04-20 14:51:12
noop

noop() Instance Public methods Issues a NOOP command. Does

2015-04-20 14:38:19
retrbinary

retrbinary(cmd, blocksize, rest_offset = nil) Instance Public methods Puts the

2015-04-20 15:06:38
mtime

mtime(filename, local = false) Instance Public methods Returns the last modification

2015-04-20 14:29:37
binary=

binary=(newmode) Instance Public methods A setter to toggle transfers in binary

2015-04-20 13:11:48
storbinary

storbinary(cmd, file, blocksize, rest_offset = nil) Instance Public methods Puts

2015-04-20 15:35:22