Quantcast
Channel: Chilkat Forum - latest questions
Viewing all articles
Browse latest Browse all 1061

Perl CkByteData and CkZip

$
0
0

I'm trying to generate a zip file entirely in memory, but I am struggling with understanding how to interface CkByteData. Perl makes us lazy, so we don't think much about data types.

Can someone offer feedback on what I'm doing wrong in this example:

#!/usr/bin/perl

use chilkat;

my $zip = new chilkat::CkZip();
$zip->UnlockComponent("XXXXXXXXX");

my $dataobj = new chilkat::CkByteData();
$dataobj->appendStr("TEST ZIP TEXT");

my $success = $zip->NewZip("test.txt.zip");
if ($success != 1) { print $zip->lastErrorText()."\n"; exit; }

my $success = $zip->AppendData("test.txt",$dataobj);
if ($success != 1) { print $zip->lastErrorText()."\n"; exit; }

my $zipdataobj = new chilkat::CkByteData();
my $success = $zip->WriteToMemory($zipdataobj);
if ($success != 1) { print $zip->lastErrorText()."\n"; exit; }

open(FILE,">test.zip");
print FILE $zipdataobj->getData();
close(FILE);


Viewing all articles
Browse latest Browse all 1061