I am trying to update translation file directly by downloading and storing it in application directory.
Below is my code,
private downloadLanguageFile(url: string, lang: string) {
const appDir = this.file.applicationDirectory;
let promise = this.http.get(url, {responseType: 'blob'}).toPromise();
promise.then((downloadedFile: any) => {
this.file.writeFile(appDir, `${lang}.json`, downloadedFile, {replace: true})
.then((data) => {
console.log(data);
}, (error) => {
console.log("error writing file", error);
})
}, (error) => {
console.log("Download language file failed", error);
});
return promise;
}
but instead of saving file in that directotry it is throwing this error:
FileError {code: 1, message: "NOT_FOUND_ERR"}
code: 1
message: "NOT_FOUND_ERR"
__proto__: Object
Code works perfectly when I change the file directory to dataDirectory.
Any suggestions on what am I doing wrong?