redhotpenguin / perl-Archive-Zip

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

Streaming to STDOUT, potentially avoiding large temp files. #90

Open davehodg opened 3 years ago

davehodg commented 3 years ago

Is this possible? Worse still we're currently on Centos 7 (v1.30) but upgrading shouldn't be hard.

pmqs commented 3 years ago

No, don't think so.

There is a similar module, called Archive::Zip::SimpleZip, that will do what you want (full disclosure - I am the author)

Here is an example that writes a zip file directly to stdout without any temporary files at all

use Archive::Zip::SimpleZip qw($SimpleZipError) ;

my $zipData ;
my $z = new Archive::Zip::SimpleZip '-',
                    Stream => 1
    or die "$SimpleZipError\n" ;

$z->add("file1.txt");
$z->close();
davehodg commented 3 years ago

This looks really plausible. How has it moved on since 1.30 (Centos 7)?

angwe commented 3 years ago

writeToFileHandle() could be used on STDOUT, I think, or just use IO::File to create a handle to do what you want, see the example at:

https://metacpan.org/pod/Archive::Zip#writeToFileHandle(-$fileHandle-[,-$seekable]-)

As a user of RHEL 7, I recommend just using CPAN to update the module to 1.68, not waiting for the yum/dnf package to update.