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

1
require 'net/ftp'

Example 1

1
2
3
4
5
6
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

1
2
3
4
5
6
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
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
voidcmd
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
login
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
putbinaryfile
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
noop
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
pwd
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
puttextfile
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
acct
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

acct(account) Instance Public methods Sends the ACCT command.

2025-01-10 15:47:30
list
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
binary=
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30