joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.84k stars 784 forks source link

how i can clear cache in app using rn-fetch-blob? #552

Open minh-dai opened 4 years ago

iqbalfaisal commented 4 years ago

https://github.com/joltup/rn-fetch-blob#cache-file-management

minh-dai commented 4 years ago

@iqbalfaisal i want to clear all folder cache app not file

etsraphael commented 3 years ago

Somebody found a solution ??

ZeviLiao commented 2 years ago

added RNFS (react-native-fs) for reading all files in the folder.

let dirs = RNFetchBlob.fs.dirs
let folderPath = dirs.CacheDir // cached folder.
await RNFS.readDir(folderPath)
    .then((f) => {
        return Promise.all(f.map(e => {
            if (e.path.indexOf('xxx-video') > -1) {  // specify filter
                // console.log('to delete paths', `${e.path}`)
                RNFetchBlob.fs.unlink(`${e.path}`)
            }
        }));
    })