Creating a Zip file from HTTP data stream

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,

I am facing some problems in creating a zip file coming as HTTP data
stream in perl running over Linux RedHat 4. The actual scenario is
that I am recieving a data stream send by a .Net application running
on windows XP that sends the stream by just reading and sending all
the bytes from a zip file. My logs displays all the data recieved in
the varialbe $$params on console but i am unable to create a zip
file out of that. Any help in this regards will be appreciated.

use core qw ( CGI_USER ) ;
use utils::MailMime;
my $osysconfig = sysconfig->new({MINIMAL => '1'});
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );

my $params = CGI::Vars();
use Archive::Zip qw( :ERROR_CODES );
#print "Content-type:text/html\n\n";
print header;

my $MAILTO = '';

my $MAILFROM = '';

my $smtp = $osysconfig->GetSMTPServer();
my $port = $osysconfig->GetSMTPServerPort();
my $host = hostname();
my $omailer = MailMime->new( { SMTPSERVER=> $smtp, SMTPSERVERPORT =>
$port } );

# $$params ---- this is the binary zipped file which i have to
attached with email.
if (($$params) and (not $$params))
$file = '/tmp/' ;
#use Archive::Zip;

#my $zip = new Archive::Zip;

#my $data = "$$params";

#print FILE $$params;
#close FILE;

#give read write permission to all
#`chmod 666 $file`;
my $fh;
#open ( $fh , '>', $file ) or $core::logger->Die( 'Error opening
file', $@);

#print $fh "$$params";
#if (defined $$params);
#print $fh $$params
#if (defined $$params);
close $fh;


my $text = "Application logs are attached\n\nDetails of the sender:\n
\nLogin:$$params \nServer Address: $host";
$text .= "\n\n$$params" if ( $$params );
my %Ret;

if (($$params) and (not $$params))
%Ret = $omailer->SendFile({

From => $MAILFROM,
To => $MAILTO,
Subject => "Application Report from $$params on $host",
Text => $text ,
Path => $file,
Type => 'binary'
}) or die "Could not send mail [$!]";
if ( $@ )
print "$@\n";
print "1";


Re: Creating a Zip file from HTTP data stream

Yasir Zaheer wrote:
Quoted text here. Click to load it

Is that real code?

If you have the all the bytes of a zip file in $$params, can't you
simply 'print' that variable to a binary file without using Archive::Zip?

By the way, wouldn't that be better written as $params->?
Are you using the 'strict' and 'warnings' pragmas?


Site Timeline