I'm submitting a bug report
[x ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/
Current behavior:
When using the ionic-native/file plugin the application cannot create, move or copy a file to the Downloads folder on Android, error code 9 with message INVALID_MODIFICATION_ERR is thrown. Tried file paths: file:///storage/emulated/0/Download and file:///mnt/sdcard/Download. Writing to the app specific folders is possible (for example externalApplicationStorageDirectory). I do request READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE upon startup (which shows the modal for approving). After restarting the app creating, moving or copying a file to the Downloads folder can be done without a problem.
Expected behavior:
Writing to the Downloads folder should be possible after requesting the permission so without restarting the application
Steps to reproduce:
Related code:
let keystoreData = JSON.stringify((this.currentWallet as ILocalWallet).keyStore);
let options: IWriteOptions = {replace: true};
let storageLocation = cordova.file.externalRootDirectory + "Download";
console.log("Trying to save file to: " + storageLocation);
this.fileNative.writeFile(storageLocation, filename, keystoreData, options).then(data => {
console.log("Write file succes! Saved to location: " + storageLocation + filename);
console.log(JSON.stringify(data));
let toast = this.toastCtrl.create({
message: 'Successfully saved keystore to downloads folder!',
duration: 2000,
position: "bottom"
});
toast.present(toast);
}).catch(error => {
console.log("Error!");
console.log(JSON.stringify(error));
let toast = this.toastCtrl.create({
message: 'Please restart the application to save the file to your downloads folder.',
position: "bottom",
showCloseButton: true,
closeButtonText: 'Ok'
});
toast.present(toast);
});
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
cli packages: (/Users/danielleushuis/.nvm/versions/node/v8.11.2/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.9
Cordova Platforms : android 7.0.0 browser 5.0.3
Ionic Framework : ionic-angular 3.9.2
System:
Node : v8.11.2
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
This is critical and urgent
If anyone ends up here from Google you need to add android:requestLegacyExternalStorage="true" to the application tag in AndroidManifest.xml
I could not write to Download at all irrespective of app restart.
It is explained in Capacitor Filesystem docs
Most helpful comment
If anyone ends up here from Google you need to add
android:requestLegacyExternalStorage="true"to theapplicationtag inAndroidManifest.xmlI could not write to Download at all irrespective of app restart.
It is explained in Capacitor Filesystem docs