Reputation: 83
I have an app that saves users' photos in the NSDocumentDirectory (retrieved with path_provider) using the standard dart:io API.
In testing on iOS and Android devices this seems to be fine, and works consistently even throughout app updates.
But then I have one magic user that is different and has reported issues whenever we release an iOS update!
It appears that when I release an app update (specifically for iOS) the images stored in this folder (NSDocumentDirectory) are getting deleted or are becoming otherwise inaccessible.
I've been digging through StackOverflow and googling this to no avail, so I'm at a complete loss and worried that more people might be experiencing this issue.
Has anyone else experienced this or can you give me some ideas on where to look, before I go bald from pulling my hair out?
The functions I'm using to store/retrieve these images can be seen in this gist:
https://gist.github.com/rvbiljouw/2fd254f7a386e8a6882701bef5f59453
Thanks!
Upvotes: 8
Views: 2213
Reputation: 1006
I finally found the answer to this problem on reddit and github. Apparently the path of the documents directory changes on iOS after each app update. Therefore, one can not store absolute paths to the files stored in this directory. Instead, it is required to store the relative paths and then join them with the value returned by getApplicationDocumentsDirectory() every time to access the files.
Here are the links with further details: https://www.reddit.com/r/Flutter/comments/g4r9m2/strange_issue_with_files_being_deleted_from/
https://github.com/flutter/flutter/issues/23957
Upvotes: 12