Hello
We have written an application using AngularJS and ServiceStack that enables download of various documents indiivdually and as zip files from the server from a AngularJS based HTML client. The AngularJS/Javascript application is able to call the server side code using a REST call, and gets the binary data and assembles a blob object on the client and triggers a client side save of the file using the HTML5 W3C saveAs(). The blob's content-type is set to application/octet-stream. This functionality works fine in Chrome, FireFox, Opera and even in IE and Edge.
However, Safari throws an exception saying "Failed to load resource: Frame load interrupted". Is there a working Javscript or AngularJS example for Safari that someone can share with me which will allow me to assemble a blob of binary data streamed from the server side?
Here is the snippet of code:
var arr = results.data;
var byteArray = new Uint8Array(arr);
var blob = new Blob([byteArray], { type: 'application/octet-stream' });
var dateTime = new Date();
var outputFileName = "somefilename.zip";
saveAs(blob, outputFileName);
The approach that we are using is described here: http://stackoverflow.com/questions/2897619/using-html5-javascript-to-generate-and-save-a-file
We have tried several Javascript frameworks that try to alleviate the browser differences such as the following:
1. Download.Js (http://danml.com/download.html)
2. FileSaver.js (https://github.com/eligrey/FileSaver.js/ )
Neither of them worked for Safari. See long discussion here: https://github.com/eligrey/FileSaver.js/issues/12
We are stuck and we need to figure out what to do regarding our Safari users. Any code examples that work in Safari will be deeply appreciated!
John