How to delete a picture from PhotoLibrary?

Hi guys! Can someone help me out with this? I already asked on stackoverflow, but there are no answers.

In an Ionic 3 app I have a photo gallery which displays images from an album. It works fine, but I can’t delete an image.

A LibraryItem, as retrieved by cordova.plugins.photoLibrary.getLibrary looks like this:

creationDate: Sat Nov 04 2017 21:21:33 GMT-0400 (EDT)
fileName: "2017-10-5-1.jpg"
height: 960
id: "1937;/storage/emulated/0/Pictures/Timelapser/2017-10-5-1.jpg"
latitude: 0
longitude: 0
photoURL: "cdvphotolibrary://photo?photoId=1937%3B%2Fstorage%2Femulated%2F0%2FPictures%2FTimelapser%2F2017-10-5-1.jpg"
thumbnailURL: "cdvphotolibrary://thumbnail?photoId=1937%3B%2Fstorage%2Femulated%2F0%2FPictures%2FTimelapser%2F2017-10-5-1.jpg&width=512&height=384&quality=0.8"
width: 1280

I am trying to delete this (or any other) image file. However anything I try, Cordova throws an error and the file doesn’t seem to exist. Ionic’s manual is quite hazy at this point. This is all it says:

removeFile(path, fileName)
The parameters are pretty obvious, except what are they supposed to be? I tried everything, extracted path and filename from the photoURL value, but nothing seems to help. Neither checkFile nor removeFile seems to find the file.

1 Like