Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem saving in chrome Version 42.0.2311.90 m with FileSaver 2015-03-04 #143

Closed
siva3378 opened this issue Apr 21, 2015 · 7 comments
Closed

Comments

@siva3378
Copy link

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.

@siva3378
Copy link
Author

It happend because, My app has a global object "URL" which is actually overriding window.URL object.

@tanmayrp
Copy link

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?

@eligrey
Copy link
Owner

eligrey commented May 15, 2015

This looks like a problem with AngularJS or your code redefining URL. I cannot stop other libraries from breaking core functionality of my library.

@siva3378
Copy link
Author

@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;
                            }
                    })
                    })();  

@tanmayrp
Copy link

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.

@tanmayrp
Copy link

Woo hoo! Fixed...There was an external file reference that did have a global object named URL.
Thanks Siva!!

@mukesh3521
Copy link

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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants