My original file wouldn't download using the local method so I decided to use Node.js, as it's already packed in AppJS, and still the zip file won't execute in AppJS.
$(".export").on("click", function() {
var fs = require("fs");
var JSZip = require("jszip");
var zip = new JSZip();
zip.file("hello.txt", "Hello node!");
var content = zip.generate({type:"nodebuffer"});
// saveAs(content, "test.zip");
fs.writeFile("test.zip", content, function(err) {
if (err) throw err;
});
});
body {
background: #fff;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://stuk.github.io/jszip/dist/jszip.min.js"></script>
<script src="http://stuk.github.io/jszip-utils/dist/jszip-utils.js"></script>
<script src="http://stuk.github.io/jszip/vendor/FileSaver.js"></script>
<button class="export">Download</button>
Note: I've tried saving files using the File API, but the only want I've been able to successfully write a file in AppJS is by using Node.js as seen below.
var fs = require("fs");
fs.writeFile("hello.txt", "Hi", function(err) {
if (err) throw err;
});