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.