AutoIt
AutoIt
Gzip Compress In Memory and Base64 Encode
See more Gzip Examples
Demonstrates how to Gzip compress in-memory data and then encode the compressed data to base64.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oGzip = ObjCreate("Chilkat.Gzip")
; This example will load a file into the fileData object.
; Your application might load fileData from other sources..
$oFileData = ObjCreate("Chilkat.BinData")
$bSuccess = $oFileData.LoadFile("qa_data/xml/hamlet.xml")
If ($bSuccess <> True) Then
ConsoleWrite("Failed to load file." & @CRLF)
Exit
EndIf
; In-place compress the contents of fileData
$bSuccess = $oGzip.CompressBd($oFileData)
If ($bSuccess <> True) Then
ConsoleWrite($oGzip.LastErrorText & @CRLF)
Exit
EndIf
; Get the base64 encoded compressed data (in a single line).
Local $strBase64 = $oFileData.GetEncoded("base64")
ConsoleWrite($strBase64 & @CRLF)
ConsoleWrite("--------" & @CRLF)
; To get the base64 in multiple lines, as it might appear in MIME,
; use "base64-mime".
Local $strBase64MultiLine = $oFileData.GetEncoded("base64-mime")
ConsoleWrite($strBase64MultiLine & @CRLF)