Please Explain What Reading a Zip file Back In Means

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.
Dustin StanleyEntrepreneurAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jackie ManCommented:
Have you tried to use the gzip utility to compress the files?
ste5anSenior DeveloperCommented:
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 StanleyEntrepreneurAuthor Commented:
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 Business Longevity with As-A-Service

Using the as-a-service approach for your business model allows you to grow your revenue stream with new practice areas, without forcing you to part ways with existing clients just because they don’t fit the mold of your new service offerings.

Jackie ManCommented:
Your OS is Windows 10?
ste5anSenior DeveloperCommented:
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 StanleyEntrepreneurAuthor Commented:
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 DeveloperCommented:
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 StanleyEntrepreneurAuthor Commented:
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 StanleyEntrepreneurAuthor Commented:
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"?????

ste5anSenior DeveloperCommented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dustin StanleyEntrepreneurAuthor Commented:
Thank you for the help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.