Access denied when attaching file from blob url in IE

I have a web service that sends a file to the client as an array, which is then read into a blob:

$scope.contentType = response.headers["content-type"]; $scope.file = new Blob([response.data], { type: $scope.contentType }); $scope.fileUrl = URL.createObjectURL($scope.file); $scope.content = $sce.trustAsResourceUrl($scope.fileUrl); 

I use the object tag as a container:

 <object id="documentContainer" ng-show="loaded" ng-attr-type="{{contentType}}" ng-attr-data="{{content}}" class="document-container"></object> 

This works great in FF, chrome, mobile browsers, web browsers designed by alien species that have never had contact with humanity, etc., but not in IE.

When the object tag data parameter is set, IE responds to the console using

Error: access denied.

This is similar to some security feature in IE where it does not want to use the file as a source, since it is located on the client machine. It denies access even if you use javascript to create a new dom element with a set of data sources.

Microsoft provides its own blob methods, such as msSaveOrOpenBlob , but I need to be able to insert the file into the browser, rather than asking the user to open the file in an external application.

Does anyone know of a workaround or a way to embed blob, which can be a wide variety of file types, in IE? I would be very uninterested in reorganizing the web service and front end code to host IE, but it looks like it could be.

+8
javascript angularjs internet-explorer pdf blob
source share
1 answer

I think the answer is no. Our site generates PDFs on the fly, but we sniff the browser for what can be done with the returned PDF.

Example: http://www.cloudformatter.com/CSS2Pdf.Demos.Structures

If you are in Chrome, you can select “Insert PDF” here and it works like a charm ... if you are in IE, even if you select “Insert”, it will download the file. Because IE cannot, and we just redirect someone from IE to the download code.

http://caniuse.com/#feat=datauri

And don't make us start with what's wrong with IE, some of the pages just broke because IE stopped serializing end tags for some p tags in the document.

+2
source share

All Articles