1

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.

1 Answer 1

2

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? .

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.