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:

getbinaryfile
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

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

delete(filename) Instance Public methods Deletes a file on the server.

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

set_socket(sock, get_greeting = true) Instance Public methods WRITEME or make

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

status() Instance Public methods Returns the status (STAT command).

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

help(arg = nil) Instance Public methods Issues the HELP command.

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

open(host, user = nil, passwd = nil, acct = nil) Class Public methods A synonym

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

getdir() Instance Public methods Alias for:

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

ls(*args) Instance Public methods Alias for:

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

chdir(dirname) Instance Public methods Changes the (remote) directory.

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

site(arg) Instance Public methods Issues a SITE command.

2025-01-10 15:47:30