Node.js
Node.js
Transition from Zip.AppendString2 to Zip.AddString
Provides instructions for replacing deprecated AppendString2 method calls with AddString.Chilkat Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var success = false;
var zip = new chilkat.Zip();
// ...
// ...
var pathInZip = "example.txt";
var textData = "This is a test";
var charset = "utf-8";
// ------------------------------------------------------------------------
// The AppendString method is deprecated:
// entryObj: ZipEntry
var entryObj = zip.AppendString2(pathInZip,textData,charset);
if (zip.LastMethodSuccess == false) {
console.log(zip.LastErrorText);
return;
}
// ...
// ...
// ------------------------------------------------------------------------
// Do the equivalent using AddString.
// Instead of returning the zip entry object, we just return success/failure.
success = zip.AddString(pathInZip,textData,charset);
if (success == false) {
console.log(zip.LastErrorText);
return;
}
// Do the following if you need the zip entry object for what was just appended.
// The newly appended entry is the last one.
var ze = new chilkat.ZipEntry();
var index = zip.NumEntries - 1;
zip.EntryAt(index,ze);
}
chilkatExample();