Image Picker URI expires after updating App

Would really appreciate if anyone can share some insights with regarding to why following behavior happens:

Repro steps:

  1. make an app (call it v0)
  2. in v0 app, use image picker (provided by expo) to pick an image and store the image URI locally.
  3. update the app and publish it through Test Flight, now the app becomes v1.
  4. open the app, the URI no longer works. I couldn’t check if the file still exists on my device btw, it does not show up in XCode devices -> installed apps section for some reason.

Basically for the images I pick from Expo image picker, the URL would expire every time I update the app to a new version.

It also happens if I just use Expo to open the project (without publishing to TestFlight/rebuild binary etc), if I upgrade Expo client through app store.

My understanding is that when picking an image from expo, it makes an copy of the image to some local cache and then return the URI from there. Is it possible that the cache gets automatically cleared when version is updated? Although if that’s the behavior I would expect it to be documented somewhere.

Otherwise, am I missing something obvious here?

nvm - I didn’t realize app ID (together with the folder path) changes every time the app is updated - so I need to save relative URL instead of absolute URL.

@afflatusxImagePicker-returned URIs are in the cache path so aren’t guaranteed to persist across app restarts. You may want to use .copyAsync(...) in the file system API to copy the file to a permanent location (such as under .documentDirectory).

yup, already did :stuck_out_tongue:

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