When I use the method File.writeExistingFile once, it creates a file and writes the content in it. When using it the next time it throws an error: code 12, “PATH_EXISTS_ERR” instead of appending to the file. Am I missing something here? Thanks a lot and have a great holiday!
import { File } from 'ionic-native';
declare var cordova: any;
here is the method:
storeEntry(entry: string): void {
File.writeExistingFile(cordova.file.externalApplicationStorageDirectory, "test.txt", entry).then(_ => console.log("written to file")).catch(err => console.log(err));
}
I found some work-around that I want to share with you:
the method first tries to write to the file with the writeOption {append:true}. If it fails because there is no file yet, it will try again without append:true.
If you’ve got a better solution, I am happy for any input.
in the succes response you have nativeUrl parameter this is the file location the you can use with the nativeUrl and FileOpener plugin to open this file
Example: