-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
TypeError: Failed to construct 'File': Iterator getter is not callable. #357
Comments
http://caniuse.com/#feat=fileapi You are likely testing this on old safari, IE or edge, they only partly support File object, you can get them from file input but not create them yourself Oh, btw you have to use an array in the File constructor as well new File([blob], ...)
new File([saveText], ...) |
I have checked and it says I can use FileSaver.js in my system. I have added as an array |
You can use filesaver, but you can't use the File constructor allways. If you like you could use this to try and fix the constructor. // Fix so you can construct your own File
try {
new File([], '')
} catch (a) {
window.File = function(b, d, c) {
var blob = new Blob(b, c)
var t = c && void 0 !== c.lastModified ? new Date(c.lastModified) : new Date
Object.defineProperties(blob, {
name: {
value: d
},
lastModifiedDate: {
value: t
},
lastModified: {
value: +t
},
toString: {
value() {
return '[object File]'
}
}
})
if (window.Symbol && Symbol.toStringTag) {
Object.defineProperty(blob, Symbol.toStringTag, {
value: 'File'
})
}
return blob
}
} |
@zymr-keshav has this issue been resolved and can be closed? |
I think this will not be anything filesaver will take care of. I provided a polyfill for constructing a File but the safest way is to construct a Blob and send a filename (using both argument) |
Using macOS Sierra 10.12.5 and angular 1.6 and FileSaver v 1.3.2 and checking into Chrome 60
I need to download one HTTP response data ( object) as
inputData
as a json file and using below approachusing file type in Blob() and 2 parameters in
saveAs()
is working fineBut why this is not working when we setting 3rd parameter as file type in File() and than save this ( as per suggested in README.md)
nor even this way ( only write the file type in File() )
why we need to write file type in Blob() constructor not in File() constructor?
Kindly provide me some understanding here.
The text was updated successfully, but these errors were encountered: