![]() |
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
(Swift) 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.
func chilkatTest() { var success: Bool = false // This example demonstrates how to retrieve metadata from Gzip data // stored in a BinData object. let gzip = CkoGzip()! let bd = CkoBinData()! let json = CkoJsonObject()! // Load a Gzip file into BinData: success = bd.loadFile("example.txt.gz") if success == false { print("\(bd.lastErrorText!)") return } // Get the metadata information from the in-memory Gzip data: success = gzip.getInfoBd(bd, json: json) if success == false { print("\(gzip.lastErrorText!)") return } // Output the JSON containing metadata: print("Gzip metadata JSON:") print("\(json.emit()!)") // Access individual fields only if they exist: if json.hasMember("filename") == true { var filename: String? = json.string(of: "filename") print("Filename: \(filename!)") } if json.hasMember("comment") == true { var comment: String? = json.string(of: "comment") print("Comment: \(comment!)") } if json.hasMember("extraData") == true { var extraData: String? = json.string(of: "extraData") print("ExtraData (Base64): \(extraData!)") } } |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.