iOS is removing image files from device

Hi guys,

My app downloads images and video files from an API onto the app I’m developing for offline use. I use the FileTransfer plugin then save images/videos to the dataDirectory and files do successfully get saved. I have data stored in SQLlite which stores the file locations where these images/videos have been saved to on the device. Upon save (if iOS), I remove the “file://” prefix when saving the location and have also used Ionic’s normalizeURL function. At this stage all files work perfectly.

When revisiting the app after multiple times (the amount of times can vary - usually 3-4), some images and videos that were once loading fine now return 404s. The files that do return 404s change each time I test. Please note that it is the same set of files that are always downloaded. There is no correlation.

This works fine on Android - just not iOS.

I have also added “Library” as the persistent file location as recommended by the File plugin, using the following:

<preference name="iosPersistentFileLocation" value="Library" />

If anyone has any advice on how to make these files persist in storage or reasoning behind why these files suddenly start returning 404s please advise.

Thanks in advance.

UPDATE: Since iOS changes the directory name that the files are in on each update, I am only storing the filename in SQLlite. On load of the app, I prepend the file.dataDirectory to each filename to get the actual path. I’ve checked (I may be wrong) but in production, the directory name will change with each update.

It appears that each time the app is deployed (hopefully just whilst developing) the data directory changes for the app.

For example, on initial load the location was:

The next time the app was deployed, the directory/GUID changed to:

So the files are still there, but under a different GUID. I’m just not sure whether the GUID remains consistent if the app is in production. If not, the only solution is to save the filename after the data directory and on load add the data directory path before the file.

If anyone has any experience on this matter, please advise. Thanks.