Reputation: 75
Am trying to use react-native-fetch-blob to create directories and paths. How do i use it? i try to use this but i cant find the directory i created.
RNFetchBlob.fs.mkdir(PATH_TO_CREATE)
.then(() => { ... })
.catch((err) => { ... })
But when i console the list of directories, i cant find it.
const dirs = RNFetchBlob.fs.dirs
console.log(dirs)
i try to console the directory but i cant find it. Also how to do i use the 'createFile' Command.
Upvotes: 1
Views: 3460
Reputation: 21
I was facing the same issue. Try this: Suppose you need to create a folder named 'Unread_Books'.
const dirs = RNFetchBlob.fs.dirs; //Use the dir API
const Unread_Books = dirs.DocumentDir + '/Unread_Books';
RNFetchBlob.fs
.mkdir(Unread_Books)
.catch(err => {
console.log(err);
});
console.log(dirs.DocumentDir);
console.log(Unread_Books);
Also check docs for further reference, https://github.com/joltup/rn-fetch-blob/wiki/File-System-Access-API#assetfilenamestringstring .
For create file refer here, How to create a file and store it inside download folder android? .
Upvotes: 2