· May 25, 2017

Can we pull .zip file using webservice call into ensemble and unzip it

I need to pull .zip file and unzip it to access the zip files contained in the archive using the web service call. Can any one suggest is there any option for to get the zip files.

Discussion (7)3
Log in or sign up to continue

Hi, Vineeth!

See the sample of exporting and importing global to zip file on the fly from @Eduard Lebedyuk post:

set ^dbg=123
set s=##class(%Stream.FileBinaryGzip).%New()
do s.LinkToFile("1.xml")
do $System.OBJ.ExportToStream("dbg*.GBL", s)
do s.%Save()
kill ^dbg
set s=##class(%Stream.FileBinaryGzip).%New()
do s.LinkToFile("1.xml")
do $System.OBJ.LoadStream(s)
write ^dbg

Hope that helps.

For those who are looking for unziping features, Embedded Python (for IRIS 2021.2+) allows you to use zipfile Python lib. For instance:

ClassMethod UnZip(pZipFileName As %String, pExtractToDir As %String) [ Language = python ]
    #; solution based on this one:
    import zipfile
    with zipfile.ZipFile(pZipFileName, 'r') as zip_ref:


ClassMethod UnZip2(pZipFileName As %String, pExtractToDir As %String)
    Set zipfile = $SYSTEM.Python.Import("zipfile")
    Do zipfile.ZipFile(pZipFileName, "r").extractall(pExtractToDir)

Tested on iris-ml-community:2021.2.0.617.0-zpm