chunlou has asked for the wisdom of the Perl Monks concerning the following question:

When you transfer or download a large file over a network (via http, ftp or some other protocols) and get interrupted, how do you resume from where you're left off instead of transfering the whole file again from the scratch?

Thanks.

Replies are listed 'Best First'.
Re: Resume failed file transfer
by arthas (Hermit) on Jul 19, 2003 at 12:28 UTC

    Hi!

    Is FTP is the protocol, use Net::FTP. You can resume a file transfer from where is was interrupted by using the following syntax:

    $result = $ftp->get($remotefile, $localfile, $offset);

    In $offset you can specify the position from where the transfer should start. For HTTP, you can use LWP this way:

    $request->header('Range' => "bytes=$local_size-$remote_size");

    This should be added as an header to the request for the file.

    Hope this helps!

    Michele.