From: Dy Dymy Date: 2009-04-16T08:49:13+09:00 Subject: Re: how to know if completely donwloaded Luke Cowell wrote: > Dy Dymy wrote: >> guy please help me... i cant detect if internet connection cuts the file >> will be corrupted... > > It appears that you have already downloaded the files and are attempting > to validate them after the download process is complete. > > I'd suggest a couple of different strategies: one would be to have the > download process raise an error if the download does not complete and > the other would be to check the files against the server you are > downloading from. If possible use an md5 checksum and otherwise you > could check the size. > > If you were downloading zip, gzip files or some other compressed format > they will usually have built in checksumming, so you could verify the > file that way. Other file formats might have ways of being validated > too. > > Luke hi Luke, thanks for the reply... firstly its correct that i am validating files after i download the file. "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. "check the files against the server you are downloading from." question: how do i check the files against the server? "md5 checksum" question: what is md5 checksum? "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 thank ahead... -- Posted via http://www.ruby-forum.com/.