Corrupt zip file downloaded in angular

Angular client code:

         $'/zip', {
            id: _id
        .success(function (data, status, headers, config) {
            var blob = new Blob([data], {type: "application/zip"});
            var contentDisp = headers('content-disposition');
            if (contentDisp && /^attachment/i.test(contentDisp)) {
                var fileName = contentDisp.toLowerCase()
                    .replace(/"/g, '');
                //The below command works but generates a corrupt zip file.
                FileSaver.saveAs(blob, fileName);
        .error(function () {
            console.log("Could not download");

NodeJS Server Code:

        .post(function(req, res) {

          var output = fs.createWriteStream(join(outdir, outzipfile));
          //Using s3zip to archive.
           .archive({ s3: s3Client, bucket: bucket}, folder, s3_files)

          output.on('close', function() {
             //This sends back a zip file.
    + outputBcemFile);

          output.on('error', function(err) {
             return res.status(500).json({error: "Internal Server Error"});


Although FileSaver.saveAs works and downloads the zip file, it seems to be corrupted. Is the type “application/zip” correct? I have also tried “octet/stream” and it downloads a corrupt zip file too. Any help would be highly invaluable! Thanks.

Source: AngularJS