FileSaver saveAs not working in IE11

1.2k views Asked by At

I'm currently using the jszip, jszip-utils, and FileSaver to zip and download several PDFs.

self.createZip = function () {
    var docs = self.list.filteredItems();
    var zip = new JSZip();
    var count = 0;
    var zipFilename = "zipFilename.zip";

    docs.forEach(function (item) {
        var filename = item.formDesc() + "_" + item.id() + ".pdf";
        // loading a file and add it in a zip file
        JSZipUtils.getBinaryContent('../career/document/StreamFile/?path=' + item.fileName(), function (err, data) {
            if (err) {
                throw err; // or handle the error
            }
            zip.file(filename, data, { binary: true });
            count++;
            if (count == docs.length) {
                zip.generateAsync({ type: 'blob' }).then(function (content) {
                     try {
                             saveAs(content, zipFilename);
                        } catch (e) {
                            console.log(e);
                        }                   
                });                
            }
        });
    });

This function currently works on all latest browsers except IE11. In IE11 is gets all the files, but Hangs on saveAs.

1

There are 1 answers

1
Elena Maximova On BEST ANSWER

Try the following after your SaveAs statement to clear the buffer

content = null;