From: Luke Cowell Date: 2009-04-16T23:58:08+09:00 Subject: Re: how to know if completely downloaded > > "raise an error if the download does not complete" > question: Where i will put my raise error in my code?... i put a "begin > - rescue - else - end" in my code... hardest part is ".read" has no > error exemption to check if it reads all throughout the file. > I'm talking about adding an exception into the code that does the downloading, not the code that reads off the disk. If you can detect that a download has ended unexpectedly, you can queue the download to start again. > "check the files against the server you are downloading from." > question: how do i check the files against the server? > By md5 checksum or the file size. > "md5 checksum" > question: what is md5 checksum? > Do some googling my friend. > "check the size" > comment: after i made this thread, i added my code to check the size. > Before i download the file i check the size using "uri meta .length" and > compare it after i download it using "File.size"... but still no use > because if it break at ".read" the size that i will get is still same as > what i downloaded... meaning uri.length = File.size > If you know the length the content is supposed to be doing something like this: Net::HTTP.start("www.example.com", 80) {|res| h = res.head("/"); puts h.to_yaml } You can check that against the size of the downloaded file. I think I might be able to help you more if you posted your download code. > thank ahead... No problem. Luke -- Posted via http://www.ruby-forum.com/.