Why can files disappear from FileSystem.documentDirectory?

My app uses FileSystem.documentDirectory to save user-submitted images that are then displayed in the app. I got a report from an iOS user that none of their images are loading. It seems as if their documentDirectory was erased. Their other data that was in AsyncStorage is still there, so they didn’t just reinstall the app. How do I figure out what happened here? Is documentDirectory not meant to be used for persistent storage? Why might the files there disappear?

1 Like

Hey @seveneightn9ne,

Thanks for reporting this. Do you by chance know what device they were using? Also, what SDK version is your project built with?

Cheers,
Adam

The user is on an iPhone but I don’t know what version. I’ll note that my app has been out on Android for a long time and I never saw this problem, but I just released for iOS a few weeks ago and now got this report. My app is on SDK 31.

I’m having this same issue. On both iOS and Android, files in the documentDirectory get cleared after some time. This is with SDK 32

I’ve noticed this in my detached app (SDK 33) when I install new versions via react-native run-ios, but I reeeeeeally hope it’s not an issue for updates from the app store, as @seveneightn9ne seems to be indicating. :grimacing:

See also https://github.com/expo/expo/issues/4261#issuecomment-501092750

Hey Brett - to be clear, I think there are 2 separate issues. The linked Github issue is about the document directory changing during reinstalls which makes the files inaccessible, whereas this is about the files disappearing while the document directory stays the same.