AutoIt
AutoIt
Download a Zip from a URL and OpenBd. (No .zip file is created)
See more Zip Examples
Demonstrates how to download a .zip from a URL, opens the Zip, and gets the contents of a file. No file is ever written.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
$oBd = ObjCreate("Chilkat.BinData")
; This URL is valid and can be tested...
$bSuccess = $oHttp.QuickGetBd("https://chilkatdownload.com/example_data/hamlet.zip",$oBd)
If ($oHttp.LastMethodSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
$oZip = ObjCreate("Chilkat.Zip")
; Open the zip from the bytes contained in bd.
$bSuccess = $oZip.OpenBd($oBd)
If ($bSuccess = False) Then
ConsoleWrite($oZip.LastErrorText & @CRLF)
Exit
EndIf
; Get the entry for the file we want..
$oEntry = ObjCreate("Chilkat.ZipEntry")
$bSuccess = $oZip.EntryOf("hamlet.xml",$oEntry)
If ($bSuccess = False) Then
ConsoleWrite($oZip.LastErrorText & @CRLF)
Exit
EndIf
; Convert all line endings to CRLF (if needed)
Local $iLineEndingBehavior = 2
Local $sXmlStr = $oEntry.UnzipToString($iLineEndingBehavior,"utf-8")
If ($oEntry.LastMethodSuccess = False) Then
ConsoleWrite($oEntry.LastErrorText & @CRLF)
Exit
EndIf
; The XML in this case is about 274K, so let's just examine the last 20 lines...
$oSb = ObjCreate("Chilkat.StringBuilder")
$oSb.Append($sXmlStr)
ConsoleWrite($oSb.LastNLines(20,True) & @CRLF)