react-nativereact-native-fetch-blob

How do i access my downloaded file from React Native Fetch Blob?


I was wondering how to access my downloaded file for Android in React Native.

This is my code:

import RNFetchBlob from 'rn-fetch-blob';
...

let response = await RNFetchBlob.config({ trusty: validateCertificate, fileCache: true, appendExt: 'zip' }).fetch('GET', ...)
                        .progress((received, total) => { console.log('progress', received / total) })
                        .then((res) => { source = res.path(); console.log('The file saved to ', res.path()) })
                        .catch(async (error) => { console.error(error); });
                console.log("this is source path: " + source);

                target = source.substring(0, source.lastIndexOf("/") + 1) + 'all_lists';
                console.log('this is target folder: ' + target);


                //Creates a folder called all_lists
                RNFetchBlob.fs
                        .mkdir(target)
                        .catch((err) => { console.log(err); });

The console logs that the folder where my data goes is "/data/user/0/com.test/files/all_lists".

However, I can't find any files in my android emulator device after "/data/usr/0/com.test/files" and I don't know how to access this folder on my computer.

I was hoping someone could help me out! Thank you so much


Solution

  • "/data/user/0/com.test/files/all_lists" is a folder inside internal storage. That means you cannot open it in a file explorer, unless you have root access.

    If you want to see them without rooting your phone I suggest you save your files in external storage. RNFetchBlob has constants that maps to some folders that might be useful for this purpose.

    https://github.com/joltup/rn-fetch-blob/wiki/File-System-Access-API#dirs