redhotpenguin / perl-Archive-Zip

Archive::Zip as seen at https://metacpan.org/pod/Archive::Zip
Other
15 stars 44 forks source link

Read files contained in ZIP file that is in another ZIP file #78

Open hdsbob opened 4 years ago

hdsbob commented 4 years ago

I have a PERL program that uses this code to read the contents of files that are within a ZIP file and it works GREAT!! The actual file that I receive to process is actually a ZIP file that contains several other embedded ZIP files and it those internal ZIP files that contain txt files that I need to read. To process the files I have to unzip the original file first so that MemberRead can be used to open the txt file members.

Is there a way to read the contents of the ZIP files that are within the original ZIP file and get the same member contents without unzipping the original file? I have tried different options and combinations to do that but, unless I'm missing something, it can't get it to work..

I would appreciate any advice or information that you can provide.

pmqs commented 4 years ago

The short answer is no. If you have multiple layers of zip files, you have to uncompress the outer one to get to the inner one.

Some options

  1. Store the inner zip file to disk & read the text file from the saves zip file.

  2. If the inner zip files aren't too big you could get A::Z to store the inner zip in a scalar and then use technique shown in the file examples/readScalar.pl to read it.

  3. I have different a module called Archive::Zip::StreamedUnzip that can deal with nested zip files - see here for an example.