Archived Forum Post

Index of archived forum posts

Question:

Missing zip.OpenFromWeb method in v9.5.0?

Apr 07 '14 at 13:22

The OpenFromWeb method does not exist in Chilkat v9.5.0. Is it possible to open a .zip from a URL?


Answer

The OpenFromWeb method was removed from the Chilkat.Zip API because it created dependencies w/ too much internal infrastructure (extra baggage) relating to HTTP, SSL/TLS, and everything network, socket, encryption, and PKCS related, which is quite a large amount of internal code. The removal is necessary for many situations where smaller link sizes are important. To workaround, one would need to first download the .zip into memory or to a file, and then open.

Here is an example in Visual Basic 6.0 using the Chilkat ActiveX to download first into memory, and then open from memory. (The OpenFromWeb method downloaded the entire .zip into memory prior to opening anyway.)

Private Sub OpenFromWeb_Click()

Dim Http As ChilkatHttp
Set Http = New ChilkatHttp

Dim Zip As ChilkatZip
Set Zip = New ChilkatZip

Dim success As Long
success = Http.UnlockComponent("30-day trial")
If (success <> 1) Then
    Text1.Text = Text1.Text & Http.LastErrorText & vbCrLf
    Exit Sub
End If
success = Zip.UnlockComponent("30-day trial")
If (success <> 1) Then
    Text1.Text = Text1.Text & Zip.LastErrorText & vbCrLf
    Exit Sub
End If

' First download the zip into memory:
Dim zipFileInMemory() As Byte
zipFileInMemory = Http.QuickGet("http://www.chilkatsoft.com/download/chilkat-9.5.0-jdk8-win32.zip")
If (Http.LastStatus = 404) Or (UBound(zipFileInMemory) = 0) Then
    Text1.Text = Text1.Text & Http.LastErrorText & vbCrLf
    Exit Sub
End If

' Now open it from memory. success = Zip.OpenFromMemory(zipFileInMemory) If (success <> 1) Then Text1.Text = Text1.Text & Zip.LastErrorText & vbCrLf Exit Sub End If

MsgBox "Num zip entries: " + Str(Zip.NumEntries)

End Sub