I am using the following code to download a handful of .csv files from my FTP server:
require 'net/ftp'
ftp = Net::FTP.new
ftp.connect('myftpserver.com', '21')
ftp.login('mylogin', 'mypassword')
ftp.passive = true
files = ftp.list
puts files
ftp.gettextfile('cutandsold-us.csv', './lib/cutandsold-us.csv')
puts "#{Time.now} > Downloaded Cut and Sold report (US)."
ftp.gettextfile('cutandsold-canada.csv', './lib/cutandsold-canada.csv')
puts "#{Time.now} > Downloaded Cut and Sold report (CAN)."
ftp.gettextfile('stylemaster.csv', './lib/stylemaster.csv')
puts "#{Time.now} > Downloaded Style Master."
ftp.gettextfile('acct-bookings-large.csv', './lib/acct-bookings-large.csv')
puts "#{Time.now} > Downloaded Account Bookings report."
ftp.gettextfile('acctbookings-majors.csv', './lib/acctbookings-majors.csv')
puts "#{Time.now} > Downloaded Major Account Bookings report."
ftp.gettextfile('customerlist.csv', './lib/customerlist.csv')
puts "#{Time.now} > Downloaded Customer list."
ftp.close
All of the files download fine except for "customerlist.csv", despite this file being on the FTP server (I can download using FileZilla), and it shows up with the correct filename in the console when "puts files" occurs.
When the line to download "customerlist.csv" is reached, the following error is returned:
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/ftp.rb:341:in `voidresp': 150 0.085 seconds (measured here), 1.11 Mbytes per second (Net::FTPReplyError)
I suspect it is an issue with the file itself and not my code as the other files download without issue, but I am not sure because the file appears to be intact and I can download it with another FTP client.
Aucun commentaire:
Enregistrer un commentaire