'Corrupt zip file getting downloaded in angular

$http({
            method: 'GET',
            url: url,
            responseType: 'arraybuffer'
        }).then(function(data) {
            var octetStreamMime = 'application/octet-stream';
            var headers = data.headers();
            var contentType = headers[octetStreamMime];
            var blob = new Blob([data.data], {type: contentType});

            fileSaver.saveAs(blob, fileToDownload);
        }).catch(function() {
            var errorMessage = "Download Failure";

            FileExplorerService.showFailureMessage(true, errorMessage);
            
        });

I am trying to download a zip file using the above angular code. ZIP file is getting downloaded successfully but on unzip I am getting the below error:

enter image description here

I have referred some other article but it doesn't work: Corrupt zip file downloaded in angular https://github.com/eligrey/FileSaver.js/issues/156



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source