Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49172

Javascript to create a zip file

$
0
0

@ank5 wrote:

I have an ionic app in which I need to create zip of some files on the device and send them to node server.

I am trying to use JSZip [http://stuk.github.io/jszip/] to create a zip of the files on the device. I have complete path of each of the files which is send to the function in filesList array.

// complete path of all the files that need to be zipped is in filesList array
// Eg., file:///var/mobile/Containers/Data/Application/BACCA40A-56C4-4BE5-8C5D-1576960BD14B/Library/NoCloud/1473447800255.zip
  var zipFiles = function(filesList) {
            var uniqueFilename = Date.now();
            var zip = new JSZip();
            // create a zip with a unique name
            var zipFolder = zip.folder(uniqueFilename);
            //add files to the zip
            filesList.forEach(function(file) {
               zipFolder.file(file);
            })
            return zipFolder;
   }

I would like to create a zip in memory (don't need to save it on the device) and send it to node.

The code above is resulting in an empty zip even though filesList array has 5 files and the path to those files is also valid.

Can someone please help me in getting this correct or is there an alternate library that I should be using.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49172

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>