Hi,
I’m getting some weird quirks when attempting to display images that I’m saving to the dataDirectory
using the File plugin. I’m saving a photo, then storing that photo’s location and displaying it in an image tag. Everything works fine the first time through, the picture saves, I store the location, and the image shows. However, when I restart the app and try to point to that file again, nothing shows up. Here is the code I’m working with:
me.file.writeFile(cordova.file.dataDirectory, filename, data, true).then(function(result){
console.log('file was saved');
console.log(result);
me.item.images.push(cordova.file.dataDirectory + filename);
//save the inspection and go back
me.inspectionProvider.save(me.inspection).then(ins => {
me.navCtrl.pop();
})
}).catch(function(err){
console.log("Could not save photo");
console.log(err);
me.toastCtrl.create(
{
message: "Could not save photo",
position: "bottom",
duration: 2000
}
).present();
})
The resulting images
array looks something like this:
["file:///var/mobile/Containers/Data/Application/xxx-xxx-xxx/Library/NoCloud/b1ca377b-3003-0b43-bc80-0c9c9ba04d85.jpg"]
I’ve confirmed that the array contents don’t change across restarts, and I’ve verified that the file is indeed there. Can anyone help point me in the right direction?
Thanks