B4J Question Create zip file with SithasoDaisy

asales

Expert
Licensed User
Longtime User
I use the SithasoDaisy to create a form - to the user fill some fields - and download a file (json), using this code:
B4X:
Dim txt As String = banano.ToJson(ToMap)   
app.Download(txt, file_name & ".cad")

It works fine in the computer browser, but in the mobile browser the extension (.cad) is change to .txt and when I attach the file into WhatsApp the name change to "null.txt".

I think that I could save the json as a zip file to avoid this.

Could I use this PizZipUtils object - from this example - to make this?

Thanks in advance for any help.
 

Mashiane

Expert
Licensed User
Longtime User
app.Download(txt, file_name & ".cad")
App.download is a shortcut to...

B4X:
'save text to a file
Sub DownloadText2File(content As String, fileName As String)
    Dim fc As List
    fc.Initialize
    fc.Add(content)
    Dim blob As BANanoObject
    blob.Initialize2("Blob",Array(fc, CreateMap("type": "text/plain;charset=utf-8")))
    BANano.RunJavascriptMethod("saveAs",Array(blob,fileName))
End Sub

I will look into zip production.
 
Upvote 0
Top