Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know whether the ftp upload via ruby is success?

Tags:

ruby

ftp

The following code uploads the file via ftp and it works.

require 'net/ftp'
ftp = Net::FTP.new
ftp.passive = true
ftp.connect("***")
ftp.login("***","***")
ftp.chdir "claimsecure-xml-files"
ftp.putbinaryfile("file.xls",File.basename("file.xls"))
ftp.quit

But how can I assure whether the upload was successful?

like image 292
Autodidact Avatar asked Jan 20 '11 06:01

Autodidact


2 Answers

after

    ftp.putbinaryfile("file.xls",File.basename("file.xls"))

check

    puts ftp.last_response
like image 61
pbr_pl Avatar answered Oct 23 '22 05:10

pbr_pl


Crudely - you could "get" the file back and ensure its the same...

like image 32
Chris Kimpton Avatar answered Oct 23 '22 05:10

Chris Kimpton