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

createObjectURL #53

Closed
shahind opened this issue Sep 15, 2022 · 4 comments
Closed

createObjectURL #53

shahind opened this issue Sep 15, 2022 · 4 comments

Comments

@shahind
Copy link

shahind commented Sep 15, 2022

When trying to use it in a Cordova-electron app I get this error:
Uncaught (in promise) TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.
at t. (js-file-downloader.min.js:10)

(does not depend on the file type or server).

@AleeeKoi
Copy link
Owner

Hi @shahind , it's probably related to cordova electron.
This lib is born to support download in browser web app, the createObjectURL is part of the Web APIs.
I think you need to find a poly lib (or create it) to make this method available in your project.
Bye

@shahind
Copy link
Author

shahind commented Sep 16, 2022

Thanks @AleeeKoi. The problem is not createObjectURL. Cordova uses chromium or the internal browser, and as far as I checked, the createObjectURL is available. The problem is actually the cordova-plugin-file that seems to be overriding the native File object. This consequently affects the downloadedFile.

@shahind
Copy link
Author

shahind commented Sep 16, 2022

For any other person who faces this problem; there is no fix for this bug so far (see the related issue). To fix the problem, you need to save the window.File and window.FileReader before executing the Cordova, for example in your index.html before Cordova.js script tag (e.g. window.originalFile=window.File). You can re-assign them in the mounted function, or you may change the js-file-downloader as I did by replacing File and FileReader with originalFile and originalFileReader.(sorry @AleeeKoi :)

@AleeeKoi
Copy link
Owner

Hi @shahind thanks for the feedback and the solution. 👍

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

2 participants