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:

retrbinary

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

2015-04-20 15:06:38
pwd

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

2015-04-20 14:51:12
get

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

2015-04-20 13:43:17
putbinaryfile

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

2015-04-20 14:46:42
voidcmd

voidcmd(cmd) Instance Public methods Sends a command and expect a response beginning

2015-04-20 15:51:26
noop

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

2015-04-20 14:38:19
login

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

2015-04-20 14:11:07
list

list(*args) Instance Public methods Returns an array of file information in

2015-04-20 14:07:32
mtime

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

2015-04-20 14:29:37
storbinary

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

2015-04-20 15:35:22