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?

4 Likes

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

1 Like

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

1 Like

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 FileSystem.documentDirectory changes between TestFlight and App Store version · Issue #4261 · expo/expo · GitHub

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.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.