Hi Monks,
I am re-asking this question (which I posted about a year ago, here
https://www.perlmonks.org/?node_id=1184785) because I have yet to find an answer.
The goal is to create a zip file and stream it to the client (via the web) as it is built (the file is quite large).
The solution, offered in my last post was to use ModPerl::Registry and run it as a cgi, but that is not the route I want/need to go. Instead I am trying to get this to work with Apache2::RequestRec and Apache2::IO and run it as a module... if possible.
The block of code below streams a zip file to STDOUT, which obviously will not work (unmodified) in this case as STDOUT is tied to the Apache request object. So, I am hoping to find a workaround.
my $z = new Archive::Zip::SimpleZip '-', Stream => 1;
foreach my $file (@many_files) {
open (my $fh, $file);
$z->addFileHandle($fh, Name => $file);
close($fh);
}
$z->close();
Any help would be greatly appreciated.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.