The following exert has been edited to protect our data.

Story is that we are using a java program and embedded perl to query a database and 
get a list of files. Once the list has been obtained, we use the java application to 
zip the files, and thn we feed this zip file thru embededperl to the browser for the 
user to downlad. We use the approach shown in the following file, where we read the 
file into the $buffer and the print to OUT the contents of $buffer. We believe that 
either $buffer stops printing to OUT when it reaches a null string, or the server 
stops feeding $buffer to the browser when a null string is encountered.

Short question: Anyone got a simple script like ours (or modify ours) that handles 
feeding .zip files for download?
long question: Whats our fix? I have done a lot of reading around the site and the 
null string argument is one of the few solutions I have seen - I know this is a fix in 
v2.xxx but that is not feesable for us at the moment.

Much help appreciated in advance...


*snip*

[- use MYLIB; use  CGI qw/:standard :html3 escape/;-]
[$ var $status  $msg $file_hdl $filestate $version $offset $buffer $save_name $save_rp 
$save_type $name $filename
$]
[-
 $escmode =0;
 ($save_name, $save_rp,$save_type) = split /:/, $fdat{'filelist'};


($status,$msg,$file_hdl,$filestate,$version) = 
MYLIB::view_file('1.1',$save_name,$save_rp,$save_type);

################################################################
# NOTE!!!!!!
# the above code is just noise, but what we do have is $file_hdl which points to a 
previously created 
# zip file.

$filename="test.zip";

$http_headers_out{'Content-Disposition'} = ": attachment; filename=$filename";

$http_headers_out{'Content-type'}= 'x-application/octet-stream';
$http_headers_out{'Content-encoding'}='x-gzip';

    while (read($file_hdl, $buffer, 1024) ) {

       print OUT "$buffer";
    }

   close($file_hdl);

-]

*/snip*

Michael Clarke
IRD Open Systems Team

Level 4, Telecom House
13-27 Manners Street
Wellington

Phone: +64 (04) 8031423
Mobile: +64 021 455 218
email: [EMAIL PROTECTED]
email: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to