![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Retrieve Metadata from Gzip Data in Memory (BinData)This example demonstrates how to use the The Gzip data is first loaded into the The metadata is returned in a Note: This example requires Chilkat v11.5.0 or greater.
IncludeFile "CkBinData.pb" IncludeFile "CkGzip.pb" IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() success.i = 0 ; This example demonstrates how to retrieve metadata from Gzip data ; stored in a BinData object. gzip.i = CkGzip::ckCreate() If gzip.i = 0 Debug "Failed to create object." ProcedureReturn EndIf bd.i = CkBinData::ckCreate() If bd.i = 0 Debug "Failed to create object." ProcedureReturn EndIf json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Load a Gzip file into BinData: success = CkBinData::ckLoadFile(bd,"example.txt.gz") If success = 0 Debug CkBinData::ckLastErrorText(bd) CkGzip::ckDispose(gzip) CkBinData::ckDispose(bd) CkJsonObject::ckDispose(json) ProcedureReturn EndIf ; Get the metadata information from the in-memory Gzip data: success = CkGzip::ckGetGzipInfoBd(gzip,bd,json) If success = 0 Debug CkGzip::ckLastErrorText(gzip) CkGzip::ckDispose(gzip) CkBinData::ckDispose(bd) CkJsonObject::ckDispose(json) ProcedureReturn EndIf ; Output the JSON containing metadata: Debug "Gzip metadata JSON:" Debug CkJsonObject::ckEmit(json) ; Access individual fields only if they exist: If CkJsonObject::ckHasMember(json,"filename") = 1 filename.s = CkJsonObject::ckStringOf(json,"filename") Debug "Filename: " + filename EndIf If CkJsonObject::ckHasMember(json,"comment") = 1 comment.s = CkJsonObject::ckStringOf(json,"comment") Debug "Comment: " + comment EndIf If CkJsonObject::ckHasMember(json,"extraData") = 1 extraData.s = CkJsonObject::ckStringOf(json,"extraData") Debug "ExtraData (Base64): " + extraData EndIf CkGzip::ckDispose(gzip) CkBinData::ckDispose(bd) CkJsonObject::ckDispose(json) ProcedureReturn EndProcedure |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.