How to access local assets in React Native using rn-fetch-blob?

Viewed 708

I get a problem to access local assets in React Native using rn-fetch-blob, this is my directory structure :

enter image description here

I want to access file female.png from App.js, this is my script :

RNFetchBlob.fs.readFile('./female.png', 'base64')
    .then((data) => {
      console.log(data);
    })

and I always get this error :

Possible Unhandled Promise Rejection (id: 14):
Error: No such file './female.png'; ./female.png (No such file or directory)
Error: No such file './female.png'; ./female.png (No such file or directory)
    at createErrorFromErrorData (blob:http://localhost:8081/61bf342c-3b22-4e66-9eea-bf93a115f88e:16416:17)
    at blob:http://localhost:8081/61bf342c-3b22-4e66-9eea-bf93a115f88e:16368:27
    at MessageQueue.__invokeCallback (blob:http://localhost:8081/61bf342c-3b22-4e66-9eea-bf93a115f88e:17245:18)
    at blob:http://localhost:8081/61bf342c-3b22-4e66-9eea-bf93a115f88e:16976:18
    at MessageQueue.__guard (blob:http://localhost:8081/61bf342c-3b22-4e66-9eea-bf93a115f88e:17149:13)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (blob:http://localhost:8081/61bf342c-3b22-4e66-9eea-bf93a115f88e:16975:14)
    at http://localhost:8081/debugger-ui/debuggerWorker.js:80:58

Please anyone help me to access local assets using rn-fetch-blob.

Thanks.

0 Answers
Related