如何阅读React Native的文件内容? // react-native-f不起作用
我目前正在处理一个反应本应用程序,该应用程序要求用户从其手机中选择文本文件并阅读它,我已经实施了该部分,要求用户使用expo-cocument-picker < /代码>,但我无法读取文件内容。
我已经尝试使用react-native-fs
而没有任何成功:
const content = async (file_path) => {
let response = undefined;
try {
response = await RNFS.readFile(path);
} catch (err) {
showAlert("Failed to read file")
throw err;
}
return response;
}
我得到的只是以下错误:
null不是对象(评估rnfsmanager.rnfsfiletypereperegular)
此时已经阅读了与该问题有关的所有问题和堆叠式帖子,但是建议的解决方案(例如npm install-save react-native-fs
或重置高速缓存都行不通。
也许是因为我使用博览会?如何读取文件whitout react-native-fs?
编辑:我已经尝试使用 filesystem 与函数readAssTringAsync
,但它始终返回以下内容:{“ _ u”:0,“ _v”:0,” _w“:null,” _x“:null}”
我感谢帮助!
I am currently working on a react-native application that is asking the user to pick a text file from its phone and read it, I already implemented the part that ask the user to choose a file using expo-document-picker
but I cannot manage to read the file content.
I already try using react-native-fs
without any success :
const content = async (file_path) => {
let response = undefined;
try {
response = await RNFS.readFile(path);
} catch (err) {
showAlert("Failed to read file")
throw err;
}
return response;
}
All I get is the following error :
null is not an object (evaluating RNFSManager.RNFSFileTypeRegular)
At this point I have read every issues and stackOverflow post related to the problem but the suggested solutions like npm install --save react-native-fs
or reseting the cache does not work.
Perhaps it is because I use expo ? How can I read a file whitout react-native-fs ?
edit : I already tried to use FileSystem with the function readAsStringAsync
but it always return the following : {"_U":0, "_V":0, "_W": null, "_X": null}"
I appreciate the help !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论