Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Resume failed file transfer

by chunlou (Curate)
on Jul 19, 2003 at 11:31 UTC ( [id://275857]=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://275857]
Approved by arthas
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-16 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found