I am trying to use the cordova-plugin-file plugin to save documents to a local folder on the device.
I am doing the following
await this.file.checkDir(folderPath, directory).then(async res => {
console.log("checkDir", res);
await this.file.writeFile(folderPath + directory, fileName, document, options).then(res => {
console.log("fileName", fileName);
console.log("document", document);
response = {
...response,
success: true,
error: res,
data: res
};
resolve(response);
})
.catch(error => reject(error));
}).catch(async () => {
await this.file.createDir(folderPath, directory, true).then(async directory => {
await this.file.writeFile(folderPath + directory.name, fileName, document, options).then(res => {
console.log("fileName", fileName);
console.log("document", document);
response = {
...response,
success: true,
error: res,
data: res
};
resolve(response);
}).catch(error => reject(error));
})
.catch(error => reject(error));
});
});
I always get the following error
FileError: {"code":9,"message":"INVALID_MODIFICATION_ERR"}
I already tried to add this configuration to config.xml but it didn't work.
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:requestLegacyExternalStorage="true" android:usesCleartextTraffic="true" />
</edit-config>
Do you have permission in AndroidManifest.xml ?
I know that this is the same error on android device if you forgot to implement permission.