Android Question Reading a zipped data stream

Discussion in 'Android Questions' started by morphe2011, Jul 13, 2015.

  1. morphe2011

    morphe2011 Member Licensed User

    Hello All
    A client has produced a wonderful api which works great . Most of the api is standard stuff that Job.GetString can handle. However at one point the stream is a zipped file . How do I get it and and save it as a zip so that I can open it and use it's contents?

    Most Thanks for any help.
     
  2. walterf25

    walterf25 Well-Known Member Licensed User

    There is a library to read and write zip files, can't remember the name of it now, but do a search and you should be able to find it.

    Cheers,
    Walter
     
  3. morphe2011

    morphe2011 Member Licensed User

    Walter
    Thank you for the reply. I use the MLfiles library for reading and writing and it works great. My issue is in saving the file as it comes in as a file rather than a string. Normally I use FTP to download files but this data is very sensitive so that is not an option.

    Writing as a string produces an invalid zip and yes I'm already testing for Job.Success
    This is a sample of code:
    Sub JobDone (Job As HttpJob)
    Dim sResults As String
    If Job.JobName="hBook" Then
    sResults=Job.GetString
    iBo=Job.GetInputStream

    File.WriteString(ed.sAppPath,"test.zip",sResults)

    Return
    End If
    End sub

    Richard
     
  4. DonManfred

    DonManfred Expert Licensed User

  5. morphe2011

    morphe2011 Member Licensed User

    Manfred

    Thank you for the link. I've looked at it before and it is a great library however I'm either brain farting or it's the first signs of dementia (probably the latter) . B4a is and has been great. I can figure out 98% on my own but on this one I'm drawing a blank. If it was ASP.net or VB.net I'd know how to proceed. Please see my reply to Walter. Any help or direction would be most appreciated.
     
  6. DonManfred

    DonManfred Expert Licensed User

    In your JobDone inside job.success

    Use
    Code:
    OutStream = File.OpenOutput(ed.sAppPath, "test.zip"False
            
    File. Copy2(Job.GetInputStream,OutStream) ' save the file
            OutStream.Close
    to save the job-result to a file
     
    morphe2011 likes this.
  7. morphe2011

    morphe2011 Member Licensed User

    Yep a brain fart.
    Most thanks.
     
Loading...