Android Question Reading a zipped data stream

morphe2011

Member
Licensed User
Longtime 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.
 

walterf25

Expert
Licensed User
Longtime 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.
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
 
Upvote 0

morphe2011

Member
Licensed User
Longtime 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
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

morphe2011

Member
Licensed User
Longtime 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.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Please see my reply to Walter. Any help or direction would be most appreciated.
In your JobDone inside job.success

Use
B4X:
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
 
Upvote 0
Top