Ok so first i will preface with that i need to do:
1.My app needs to be able to pull an image store it locally and then use that asset in the app. The image will be different for each user but i need it stored locally so i will display even if the app is run offline. For reference this is a profile image.
2.We need translations in the app and i have that working, but we will be adding more translations over time so we want to download those json files when they are online. Translations are working in the app but they pull from assets/i18n/**.json I’d like to be able to download files and store them there.
So after a bunch of troubleshooting i was able to get files to download but i can’t seem to wrote to the assets directory
this fails:
this.fileTransfer.download("https://d30y9cdsu7xlg0.cloudfront.net/png/2048-200.png", this.file.applicationDirectory + "www/assets/2048-200.png").then((data) => {console.log(data);}, (error)=>{console.error(error);});
Could not create target file :"file:///var/containers/Bundle/Application/CD0FE1E6-B272-4DE0-AB11-4D34DCB604EF/MyApp.app/www/assets/generic_tnj_ad.jpg
I know the path is correct since
this.file.listDir(this.file.applicationDirectory, "www/assets/").then((data)=>{
console.log(data)
});
returns a list of the files/directories in the path.
There has to be something to write to that location or to a location where the app can access the files. I tried to download the files to the data directory and the file downloads properly
this.fileTransfer.download(url, this.file.dataDirectory + 'generic_tnj_ad.jpg')
However if i try to use the image in my template it can’t load the local resourc
Template:
<ion-content style="text-align:center" scroll="false">
<form (ngSubmit)="login()">
<img src="{{ headingImage }}" style="padding-top:50px">
the code to get the image path
this.headingImage = this.file.dataDirectory + 'generic_tnj_ad.jpg';
console.log(this.headingImage);
});
that code is even being run after the a reload so the file is already there.
What am i missing about uploading to assest, and what am i missing to reference files from a non assests folder?