Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 1.06 KB

how-do-i-use-backbone-js-to-zip-a-file.md

File metadata and controls

35 lines (24 loc) · 1.06 KB

How do I use backbone.js to zip a file?

// plain

Backbone.js is a JavaScript library that provides structure to web applications. It can be used to create a zip file by using the JavaScript library JSZip.

To use JSZip with Backbone.js, first include the JSZip library in your HTML page:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>

Then, create a new JSZip instance and add files to it:

var zip = new JSZip();
zip.file("Hello.txt", "Hello World\n");

Once all of the files have been added, the zip file can be generated by calling the generateAsync() method:

zip.generateAsync({type:"blob"})
    .then(function (blob) {
        saveAs(blob, "example.zip");
});

This will generate a zip file named "example.zip" that contains the file "Hello.txt".

Helpful links

onelinerhub: How do I use backbone.js to zip a file?