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.
精彩评论