开发者

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

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 "claim开发者_运维知识库secure-xml-files"
ftp.putbinaryfile("file.xls",File.basename("file.xls"))
ftp.quit

But how can I assure whether the upload was successful?


after

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

check

    puts ftp.last_response


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


Can we do this?

unless ftp.size('file.xls') == File.size('file.xls') do
  #Repeat!
end


you can upload a dummy file after uploading your excel file. Then do a listing and check that you have this dummy file. just an idea.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜