Dec 4, 2011, 8:29 PM
Post #1 of 2
how to compress the zip file.
I have a perl script that gets the content from a repository and then try to zip the content before sending as an email attachment. But it is not working need some expert advise from this forum.
Below is the extract of the perl script:
my $attachmentName = $_;
my $fileContents = $_;
my $zip = Archive::Zip->new() || die $logPrefix . "Create zip: $!\n";
my $zipString = $zip->addString($fileContents,$attachmentName);
my $status = $zip->writeToFileNamed("$attachmentName.zip");
The content of the file is actually an excel file which is 3MB in size. So after zipping it, it should be less then 3MB but in this case the content of the file size is the same after zipping it.
I did some research regarding addString and addFile, seems to me it requires the addFile in order for zipping to work. But in my scenario here, we need to extract the content from the repository thus perhaps the previous programmer uses the addString.
The question here is how to extract the content from the repository and at the same time zip up the file.
Would appreciate some advise on this issue.