Does anyone know of a way to get a status update from ruby's Net::FTP library while downloading a file? I am trying to implement a web interface that shows a progress bar for percentage remaining when downloading a file from a remote ftp server.
+1
A:
For future reference - I stumbled upon a solution:
filesize = ftp.size(filename)
transferred = 0
p "Beginning download, file size: #{filesize}"
ftp.getbinaryfile(filename, "#{SOURCE_IMPORT_DIRECTORY}/#{filename}", 1024) { |data|
transferred += data.size
percent_finished = ((transferred).to_f/filesize.to_f)*100
p "#{percent_finished.round}% complete"
}
ftp.close
smnirven
2009-11-25 05:03:29