Im trying to save ms word file using FileSaver. But I'm getting following error at "get_URL().createObjectURL"
Error: [ABC] get_URL(...).createObjectURL is not a function
TypeError: get_URL(...).createObjectURL is not a function
at new FileSaver (http://localhost:8080/web/src/js/libs/file-saver-saveas-js/FileSaver.js:129:28)
at saveAs (http://localhost:8080/web/src/js/libs/file-saver-saveas-js/FileSaver.js:211:11)
at http://localhost:8080/web/src/app/igl-services/igl.compilation.service.js:112:65
at http://localhost:8080/web/src/js/libs/angular/angular.js:9369:11
at processQueue (http://localhost:8080/web/src/js/libs/angular/angular.js:13189:27)
at http://localhost:8080/web/src/js/libs/angular/angular.js:13205:27
at Scope.$get.Scope.$eval (http://localhost:8080/web/src/js/libs/angular/angular.js:14401:28)
at Scope.$get.Scope.$digest (http://localhost:8080/web/src/js/libs/angular/angular.js:14217:31)
at Scope.$get.Scope.$apply (http://localhost:8080/web/src/js/libs/angular/angular.js:14506:24)
at done (http://localhost:8080/web/src/js/libs/angular/angular.js:9659:47) undefined
I'm able to download in IE11 but not in chrome. After I try to get the window.url object in chrome console, I found in the normal browser window.URL.createObjectURL is avaliable but in my page(using angularJS) window.URL do not have createObjectURL method.
Means, FileSaver may not work with AngularJS apps. Please correct me If am I wrong.
It happend because, My app has a global object "URL" which is actually overriding window.URL object.
Siva...I've run into the same issue.
I don't have any global objects "URL" but I do use the URL method for ajax calls. Do you think that would have this behavior as well?
This looks like a problem with AngularJS or your code redefining URL. I cannot stop other libraries from breaking core functionality of my library.
@tanmayrp I dont think it is a problem with AngularJS or any other library. It our own code overriding the URL object. What do you mean by "url method for ajax calls"?
Following code, watches exactly which code is overriding the main URL object. Keep this code in before all the script tags and run your app in browser, Check logs, I hope you can find the answer
(function () {
var _createObjectURL = window.URL.createObjectURL;
Object.defineProperty(window.URL, 'createObjectURL', {
set: function (value) {
console.trace('set createObjectURL')
_createObjectURL = value;
},
get: function () {
console.trace('get createObjectURL')
return _createObjectURL;
}
})
})();
(function () {
var _URL = window.URL;
Object.defineProperty(window, 'URL', {
set: function (value) {
console.trace('set URL')
_URL = value;
},
get: function () {
console.trace('get URL')
return _URL;
}
})
})();
Thanks for your help siva...
I meant the URL property for the Jquery Ajax function. That's the only explicit 'URL' in the code.
I've added the code to execute before all the scripts. What is the expected behavior?
I see several instances of:
get URLObject.defineProperty.get @ localhost/:34
and
set URLObject.defineProperty.set @ localhost/:29
in the browser's console window.
Woo hoo! Fixed...There was an external file reference that did have a global object named URL.
Thanks Siva!!
For me its working in I.E but nor in Google chrome , Because I have a Ajax Call in where I am setting the URL ..How to rectify this issue. As i am quite new to this technology .. So please suggest the Way out .
Most helpful comment
It happend because, My app has a global object "URL" which is actually overriding window.URL object.