On 11/30/06, Patrick Plattes <patrick / erdbeere.net> wrote:

> i have a question about downloading files. I want to download a file and
> print out how many bytes are downloaded. That's important to me, because
> i want to have a progress bar later.

> The problem is that it looks like my code downloads the whole file and
> after that it executes the while loop - this behavior is useless for me.

It would be nice if there was an easier way to handle the data as it
comes in; but if you just need to do a progress bar, Kernel.open takes
two optional parameters just for this purpose:

:content_length_proc - gets called initially w/ the document size, if it
    could be obtained in the content-length header

:progress_proc - gets called with the size of the data read so far.

It's in the rdoc for open-uri under OpenURI::OpenRead#open.


-- 
Lou.