Please Explain What Reading a Zip file Back In Means

Dustin Stanley
Dustin Stanley used Ask the Experts™
I am in the process of a project and I have came to a stump. I am making a XML with an attachment and I have to "Read Back the gZip file"????

what does that mean exactly. I have no experience in XML attachments or with zip files. Just zip it up to save space. I am using MS Access and I am sending this to an API.

Please extremely dumb it down for me. Thanks.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Jackie Man IT Manager
Top Expert 2010

Have you tried to use the gzip utility to compress the files?
ste5anSenior Developer
Well, it normally means, that gzip is used for transport compression. Thus before sending the XML you gzip it and any results you'll get are also gzipped. Thus you need to decompress the answer, before you can work with your XML.

But the keyword here is API. Just read their spec, references and documentation.
Dustin StanleyEntrepreneur


I am using Windows 7 and I have used 7zip in gzip format. It appears there is no user interface for Windows gZip.

This is used for transportation. Are you saying I gZip the file and then gZip the file again... So it is a gzip within a gZip?

or I gZip it send it and then when the server replies it will also be in gZip format. Which I have to decompress to read?

Thanks for the help. Sometimes I don't get the simplest things.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Jackie Man IT Manager
Top Expert 2010

Your OS is Windows 10?
ste5anSenior Developer

I guessed based on the keyword API - you have not given any further clue on that - that you need to gzip the payload before sending it and decompress any payload you receive.
The entire rest (pun intended) depends on your concrete API. Thus RTFM.
Dustin StanleyEntrepreneur


Jackie Man
Windows 7

you have not given any further clue on that

The API is for ebay Large Merchant Services (LMS). The calls name is "uploadFile". This is an XML file and the specs can be found here:

I also have a another API call named "AddFixedPricedItem". This is also an XML file.

So from my understanding I have to gzip the "AddFixedPricedItem"  XML file into the "uploadFile" XML file under the element <fileAttachment>.

So this is where the question here begins. I was told I had to "Read the GZIP file back in."??????

Thanks for the help!
ste5anSenior Developer
In this case you need to gzip or zip the file first. Here you can use easliy the systems zipper or 7-zip if installed. Then this is a shell call using the system zip:

Public Sub WindowsZip()

  Const FOR_WRITING As Long = 2

  Dim fso As Object
  Dim ns As Object
  Dim sha As Object
  Dim FileName As Variant
  Dim ZipFileName As Variant
  FileName = "C:\Temp\Test.txt"
  ZipFileName = "C:\Temp\"

  Set fso = CreateObject("Scripting.FileSystemObject")
  If fso.FileExists(ZipFileName) Then
    fso.DeleteFile ZipFileName
  End If
  fso.CreateTextFile(ZipFileName).Write "PK" & Chr(5) & Chr(6) & String(18, Chr(0))
  Set fso = Nothing

  Set sha = CreateObject("Shell.Application")
  Set ns = sha.Namespace(ZipFileName)
  ns.CopyHere FileName
  Set ns = Nothing
  Set sha = Nothing

End Sub

Open in new window

Or 7-zip:

Public Sub SevenZip()

  Dim SevenZip As String
  Dim CommandLine As String
  Dim FileName As String
  Dim ZipFileName As String
  FileName = "C:\Temp\Test.txt"
  ZipFileName = "C:\Temp\"
  SevenZip = "C:\Program Files\7-Zip\7z.exe"
  CommandLine = """" & SevenZip & """ a """ & ZipFileName & """ """ & FileName & """"

  Shell CommandLine
End Sub

Open in new window

Then you can use some further more system components to encode it:
Public Function EncodeFile(strPicPath As String) As String
    Const adTypeBinary = 1          ' Binary file is encoded

    ' Variables for encoding
    Dim objXML
    Dim objDocElem

    ' Variable for reading binary picture
    Dim objStream

    ' Open data stream from picture
    Set objStream = CreateObject("ADODB.Stream")
    objStream.Type = adTypeBinary
    objStream.LoadFromFile (strPicPath)

    ' Create XML Document object and root node
    ' that will contain the data
    Set objXML = CreateObject("MSXml2.DOMDocument")
    Set objDocElem = objXML.createElement("Base64Data")
    objDocElem.DataType = "bin.base64"

    ' Set binary value
    objDocElem.nodeTypedValue = objStream.Read()

    ' Get base64 value
    EncodeFile = objDocElem.Text

    ' Clean all
    Set objXML = Nothing
    Set objDocElem = Nothing
    Set objStream = Nothing

End Function

Open in new window

Dustin StanleyEntrepreneur


Thank you for the info. I have to leave work soon so I will be back in the morning to try that out. I hope it works for me as this is a big pain. I have been working all week on it. Thanks.

Also did you look over that link? If so am I correct as of what they are asking for? Thanks.
Dustin StanleyEntrepreneur


I used the code and thank you. So when someone says "Read the zip file back in." That means to encode it into Binary????  Zipped Binary file is a "Read In Data File"?????

Senior Developer
When you have a file, you can consider it to be outside of your application. They talk about zip files, thus the mean they compress the file into a zip file, still residing outside of your application. For sending the the file you need to read it "back in". Which simply means you need to read it. Then you need to encode it.

btw, "Read the zip file back in" is not really necessary. Cause you may read the original file, zip it in memory, then the zip file would in-memory, thus inside your program.. just ask them in future what they exactly mean be such terms and phrases.
Dustin StanleyEntrepreneur


Thank you for the help!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial