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 ?
Ok, I found a temporary solution.
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 ?