React Native - is there a way to find / find all images (.jpg / .png) from external / internal storage?

I am new to react based development and use RNFetchBlob

to work with files in internal storage, I wanted to create a gallery app and for that I need to get all the images present in the phone.

What I was able to do was extract all files from a specific directory and find images in it.

RNFetchBlob.fs.ls(RNFetchBlob.fs.dirs.DCIMDir).then((files) => {
        //Returns all files present in the directory
        console.log(files);
        //Returns files with .png or .jpg extension.            
        console.log(files.find((element) => {return element.match('/(.png)$|(.jpg)$|(.jpeg)$/g')}));

    }).catch((err) =>{
        console.log(err);
    });

      

But with this approach, I have to search in each directory, iterate through them using recursion.I wanted to know if there is some way to get all the image files with just one command .

+3


source to share





All Articles