我在使用rn-fetch-blob访问React Native中的本地资源时遇到问题,这是我的目录结构:
我想从App.js访问文件female.png,这是我的脚本:
RNFetchBlob.fs.readFile('./female.png', 'base64')
.then((data) => {
console.log(data);
})
我总是会收到此错误:
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
请任何人帮助我使用rn-fetch-blob访问本地资产。
谢谢。