cordova-plugin-file
cordova-plugin-file copied to clipboard
FileWriter silently fails in IFrame with 'Invalid Parameter type'
Bug Report:
FileWriter silently fails in IFrame with 'Invalid Parameter type'
Problem
A blob/pdf is written to a temporary file on the device and then opened via the platform's OS. This workes fine when the test-doc is properly compiled into its own platform app on Android or iOS.
But I want my app to come empty and be installed without it's content document, which should be downloaded and locally stored by the final user only.
When the test-doc is downloaded by a loader-app, then written to the device storage and displayed from there in an IFrame, everything looks and works fine, except this:
- When the doc's JS creates a FileWriter, all looks good, but no data gets written. No Error occurs and the empty file is passed on to the file-opener2 and finally the PDF-viewer complains about the corrupt pdf.
On iOS the console shows an error inside the FileWriter object, on Android, no errors are reported at all.
What is expected to happen?
- LoaderApp started, then loades & stores the loaderDoc web-document,
- the loaderDoc should be able to download, store, open and display a test-PDF from Github.
What does actually happen?
- pdf file size always empty (or just 2bytes)
- no errors in console on Android
- on iOS in console:
FileWritererror:'Invalid Parameter type'

Information
the cordova loaderDoc project
- can either run as is (w/o the LoaderApp) - and works fine
- or be payload for the LoaderApp, that is:
- have its www-folder downloaded as zip,
- be stored locally on the device
- and then opened from there in an IFrame
- in both cases the same code runs -
in the latter case it fails
DROP-IN www/cordova.js:
www/cordova.js of the payload document is meant to be replaced during cordova's build procress.
In two cases it won't be replaced and is used as is:
- before the raw web-doc is put inside a cordova project's www/ folder (happens on the CMS creating the doc)
- if it resides in the LoaderApp's IFrame, in this case proxies of the plugins are created inside the IFrame
Command or Code
- build the loaderDoc as a cordova app, install/run it,
see if it manages to download, write and open the test-pdf - build and run the LoaderApp, have it download the loaderDoc, save and open it, and finally have the loaderDoc fail its test-operation.
Environment, Platform, Device
Desktop Linux:
5.8.6-1-MANJARO, x86_64 GNU/Linux
Desktop OS/X:
Systemversion: macOS 10.15.6 (19G2021)
Kernel-Version: Darwin 19.6.0
Android:
Galaxy Tab-A Model SM-T510
Android-Version: 10
Kernel-Version: 4.4.177-19000394
# 1 Tue June 30 16:25:20 KST 2020
iOS:
iPAD Air 2
iOS-Version 14.0
ModelNo MGHY2FD/A
Version information
for both LoaderApp and and the loaderDoc:
> cordova --version
10.0.0
> cordova platform ls
Installed platforms:
android 9.0.0
ios 6.1.1
> cordova plugin ls
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-file-opener2 3.0.5 "File Opener2"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-whitelist 1.3.4 "Whitelist"
- jQuery 3.5.1.min.js
- jszip.min.js
Android Studio 4.0.1
Build #AI-193.6911.18.40.6626763, built on June 25, 2020
Runtime version: 1.8.0_242-release-1644-b3-6222593 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.8.6-1-MANJARO
GC: ParNew, ConcurrentMarkSweep
Memory: 1981M
Cores: 8
Registry: ide.new.welcome.screen.force=true
Non-Bundled Plugins: org.jetbrains.kotlin, com.google.services.firebase
Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above