Could not unpack file uploaded via FTP get () in Perl
I am using FTP get () to download a zip file from the server to perl, but when I try to unzip it, I cannot do it either through perl or manually (I use zip as well). But when I download the same file manually, I can unzip it manually using 7 zip.
$fpath = "filename";
my $dest = "dest";
$ftp = Net::FTP->new($host, Debug => 0)||warn("connection not made");
$ftp->login($user, $pass) || die $ftp->message;
$ftp->cwd($dir);
my $zipName = $ftp->get($fpath);
my $zip = Archive::Zip->new($zipName);
my $extractor = Archive::Extract->new( archive => $zipName );
my $ext = $extractor->extract(to=>"location");
The file size is the same as the file size
The problem cannot be resolved.
source to share
But when I download the same file manually, I can unzip it manually using 7 zip.
7zip can unpack a variety of formats, while Archive :: Zip can only do a subset, i.e. basically the original ZIP format. I suggest that your file is simply in a format supported by 7zip but not supported by Archive :: Zip. If this file had been created by archive :: Zip instead, then the problem would probably be different, because Archive :: Zip must be able to unpack the files it created.
source to share