1

I can't find how one would get (using expo packages) the local uri like file:///storage/emulated/0/DCIM/Camera/... from user picking an image from their media library without having to re-save/duplicate the image.
This gives me a paginated structure of user's photos and contains the uri I'd expect:

await MediaLibrary.getAssetsAsync({
    mediaType: [
        'photo',
    ],
});

However that does not open the media library, what does is:

await ImagePicker.launchImageLibraryAsync({
    mediaTypes: ImagePickerExpo.MediaTypeOptions.Images,
    presentationStyle: 0,
});

However uri here is something like file:///data/user/0/host.exp.exponent/cache/... which looks to me like an uri to a temporary cache, not the permanent uri to the local file.

Is there a way how to get the permanent media library uri from the image picker? (Without having to basically create your own gallery and picker using the getAssetsAsync() ?

jave.web
  • 13,880
  • 12
  • 91
  • 125

1 Answers1

1

This is my code! so help you!

if (Platform.OS === 'ios') {
const info = await MediaLibrary.getAssetInfoAsync(item.id)
const uri_local = info.localUri;
item.uri = uri_local;
console.log("test image: ", info)
}
else if (Platform.OS === 'android') 
{
                
}
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 13 '22 at 22:08