ImagePicker : unique image ID

Hi guys,

I’m using ImagePicker to choose images available on iOS and Android devices. I want to create some kind of gallery, and I want to deduplicate the images the user is choosing, but the uri returned by the component is each time different when I choose the same file …
Is there a way to get a unique ID which don’t change for each image the user selects ?

Thanks in advance for any help!

Hey @vincentj, the MediaLibrary module may be of better use here:


Thank you for your answer @adamjnav!
But this is not good for me :cry: Because this imply that I need to dev an image picker myself … :cry:

Ok, I found a temporary solution. :slight_smile:
I used FileSystem to generate a md5 checksum associated to the ImagePicker given file.

My solution is to call:
const hashMD5 = async (imageUri) => { return await FileSystem.getInfoAsync(imageUri, { md5: true } ); }

then just compare that md5 to the rest of the files already selected.
Collisions could happen with the md5 hash, but like my users will choose a maximum of 5 files, it’s a minimal risk I can face off.

May I suggest to add a unique ID returned by the ImagePicker for further versions of that module ?

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