Downloading Files via FTP Using Ruby
This article will show you how to easily download files via FTP using Ruby.
Published on:October 5, 2013
HEADS UP! This article was designed for Rails versions prior to 6.0 and Ruby 1.x. It may not be compatible with newer versions of Rails and/or Ruby.
Downloading files from an FTP server is quite easy using Ruby. Below is an example script that shows how to accomplish this.
require 'net/ftp'
ftp = Net::FTP.new
ftp.connect("myhostname.com",21)
ftp.login("myuser","my password")
ftp.chdir("/mydirectory")
ftp.passive = true
ftp.getbinaryfile("mysourcefile", "mydestfile")