B4J Library [BANano] [SithasoJsZIP] Compress & Download Files for your WebApps

Hi Fam

Assumptions:

You have a file input, you fire a change event and trap the selected file(s), you either loop through the files or just process one. This class helps you compress the files and then download them.

First, Download JSZIp

Then Add it to your project

B4X:
BANano.Header.AddJavascriptFile("jszip.min.js")

In your code...

1. Initialize the class

B4X:
'start a zip file compression
    Dim compress As SithasoZip
    compress.Initialize($"${prjName}.zip"$)

2. Add the file(s) This could be array fileinput.GetFiles / fileinput.GetFile

B4X:
compress.AddFile(fn, fo)

3. Zip the files and download them.

B4X:
'compress the files
    banano.Await(compress.Compress)
    compress.Download
 

Attachments

  • SithasoZip.bas
    1.2 KB · Views: 145
Top