3

I have a request to a web api that returns a file. I have the following javascript that places the file data in a link which then starts the download:

        function (response) {
            $scope.downloadStarted = false;
            var file = new Blob([response.data], {
                type: 'application/csv'
            });
            var fileURL = URL.createObjectURL(file);
            var installer = document.createElement('a');
            installer.href = fileURL;
            installer.target = '_blank';
            installer.download = 'Installer.EXE';
            document.body.appendChild(installer);
            installer.click();
        }

I see the data come in and it fails on the click. This works correctly in Chrome/Firefox.

The following is the error that is thrown in the console:

enter image description here

This is happening in Edge.

MaxArt
  • 22,200
  • 10
  • 82
  • 81
RichardMc
  • 844
  • 1
  • 9
  • 33

0 Answers0