Big Angry Blue Fish > Archive-StringToZip-1.03 > Archive::StringToZip

Download:
Archive-StringToZip-1.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.03   Source  

NAME ^

Archive::StringToZip - Transforms a string to a zip

SYNOPSIS ^

A simple wrapper around Archive::Zip for transforming a string to a compressed zip returned as a filehandle. Inherits all of Archive::Zip's methods.

This module operates in memory and avoids the use of temporary files. If you want to send the contents of a zip to standard output, for example, you might find this module useful.

USAGE ^

OO-style:
 use Archive::StringToZip;

 my $stz = Archive::StringToZip->new();
 my $zip = $stz->zipString($string,$filename) 
            or die "Zipping string failed";

or

Procedural-style
 use Archive::StringToZip qw(zipString);

 my $zip = zipString($string,$filename) 
            or die "Zipping string failed";

or even

Classy-style
 use Archive::StringToZip;

 my $zip = Archive::StringToZip::zipString($string,$filename) 
            or die "Zipping string failed";
Then return a zip file to a browser download
 print qq~Content-Type: application/x-zip\nContent-Disposition: attachment; Encoding: base64; filename="${filename}.zip"\n\n~;
 print $zip;

METHODS ^

new
 my $stz = Archive::StringToZip->new();

Constructs a new string zipping object

zipString
 my $zip_content = $stz->zipString($string, $filename);

or

 my $zip_content = zipString($string, $filename);

First argument is compulsory; second is optional. The default filename is file.txt if the second argument is undefined.

Converts a string ($string) into a file ($filename) in a compressed zip file format which is returned as a string.

Returns a false value on failure.

Sets binmode STDOUT by default to help prevent Win32 systems being confused about your output.

DEPENDENCIES ^

Archive::Zip and IO::String.

MOTIVATION ^

We had users wanting to carry bulk exports of data from a database representing their online store's order history. After slurping the data out and converting it, the resulting CSV was pretty big, so compression was the way forward, et voila! Archive::StringToZip was born.

AUTHORS ^

Robbie Bow and Tom Hukins sometime in spring 2006.

BUGS ^

Please report any bugs or feature requests to

bug-archive-stringtozip at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Archive-StringToZip. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ALTERNATIVES ^

IO::Compress::Zip, unstable at the time of writing.

LICENSE ^

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: