It does by implementing a fake filehandle that supports seek, implemented by using the FTP REST and ABOR commands to start the download at an arbitrary point, and end it when we've read all we want. Some FTP servers will disconnect you if you ABORt a transfer, but Net::FTP::AutoReconnect will re-connect as if nothing happened. When Archive::Zip is asked to open an archive on the fake filehandle, it doesn't even know what hit it.
Here's some sample code using these modules:
#!/usr/bin/perl use warnings; use strict; use Net::FTP; use Net::FTP::AutoReconnect; use Net::FTP::RetrHandle; use Archive::Zip; my $ftp = Net::FTP::AutoReconnect->new("ftp.info-zip.com", Debug = +> $ENV{DEBUG}) or die "connect error\n"; $ftp->login('anonymous','example@example.com') or die "login error\n"; $ftp->cwd('/pub/infozip/UNIX/LINUX') or die "cwd error\n"; my $fh = Net::FTP::RetrHandle->new($ftp,'unz551x-glibc.zip') or die "Couldn't get handle to remote file\n"; my $zip = Archive::Zip->new($fh) or die "Couldn't create Zip object\n"; foreach my $fn ($zip->memberNames()) { print "unz551-glibc.zip: $fn\n"; }
Sorry for the bit of tooting my own horn, but this was such a fun hack I had to tell somebody, and I thought that My Fellow Monks would appreciate it. :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extracting individual files from a Zip archive over FTP...
by Ace128 (Hermit) on Apr 10, 2006 at 03:46 UTC | |
|
Re: Extracting individual files from a Zip archive over FTP...
by Anonymous Monk on Oct 20, 2010 at 13:34 UTC |