login about faq

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);

asked Sep 09 at 12:27

titan's gravatar image

titan
1


Don't forget that AppendData returns a CkZipEntry object, not a success/failure indicator.

Otherwise you pretty much have it. I would wonder if you're opening the output file in binary or text mode. Given that I work in many different programmming languages, it's something I always would question, would never remember, and would always have to lookup..

Here's an example I wrote just now that will get linked from the refdocs and example-code.com shortly..

Android: Create a Zip Entirely in Memory

Classic ASP: Create a Zip Entirely in Memory

C: Create a Zip Entirely in Memory

C++: Create a Zip Entirely in Memory

C#: Create a Zip Entirely in Memory

C# UWP/WinRT: Create a Zip Entirely in Memory

DataFlex: Create a Zip Entirely in Memory

Delphi ActiveX: Create a Zip Entirely in Memory

Delphi DLL: Create a Zip Entirely in Memory

.NET Core C#: Create a Zip Entirely in Memory

Visual FoxPro: Create a Zip Entirely in Memory

Java: Create a Zip Entirely in Memory

Lianja: Create a Zip Entirely in Memory

MFC: Create a Zip Entirely in Memory

Mono C#: Create a Zip Entirely in Memory

Node.js: Create a Zip Entirely in Memory

Objective-C: Create a Zip Entirely in Memory

Perl: Create a Zip Entirely in Memory

PHP ActiveX: Create a Zip Entirely in Memory

PHP Extension: Create a Zip Entirely in Memory

PowerBuilder: Create a Zip Entirely in Memory

PowerShell: Create a Zip Entirely in Memory

Python: Create a Zip Entirely in Memory

Ruby: Create a Zip Entirely in Memory

SQL Server: Create a Zip Entirely in Memory

Swift: Create a Zip Entirely in Memory

Tcl: Create a Zip Entirely in Memory

Unicode C: Create a Zip Entirely in Memory

Unicode C++: Create a Zip Entirely in Memory

Visual Basic 6.0: Create a Zip Entirely in Memory

VB.NET: Create a Zip Entirely in Memory

VB.NET UWP/WinRT: Create a Zip Entirely in Memory

VBScript: Create a Zip Entirely in Memory

Xojo Plugin: Create a Zip Entirely in Memory

link

answered Sep 09 at 12:52

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Awesome! Thank you for those examples!

link

answered Sep 09 at 13:25

titan's gravatar image

titan
1

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×20
×19
×6

Asked: Sep 09 at 12:27

Seen: 148 times

Last updated: Sep 09 at 13:25

powered by OSQA