最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to list files in assets folder react-native - Stack Overflow

programmeradmin1浏览0评论

I created a folder with some subfolders in android/app/src/main/assets/. I re-piled the app and I am trying to get a list of the folder/files I put in there. However, whenever I run one of the following mands (from react-native-fetch-blob)

RNFetchBlob.fs.ls(RNFetchBlob.wrap(RNFetchBlob.fs.asset('subfolder/')))

or

RNFetchBlob.fs.ls("bundle-assets://")

or

RNFetchBlob.fs.ls(RNFetchBlob.fs.asset('subfolder/'))

I get

Error: ls error: failed to list path RNFetchBlob-file://bundle-assets://subfolder/ for it is not exist or it is not a folder at http://localhost:8081/index.android.b...

At least the assets folder should exist? How do I access the files in assets? Is there a way to do it without react-native-fetch-blob by simply passing a Path?

I created a folder with some subfolders in android/app/src/main/assets/. I re-piled the app and I am trying to get a list of the folder/files I put in there. However, whenever I run one of the following mands (from react-native-fetch-blob)

RNFetchBlob.fs.ls(RNFetchBlob.wrap(RNFetchBlob.fs.asset('subfolder/')))

or

RNFetchBlob.fs.ls("bundle-assets://")

or

RNFetchBlob.fs.ls(RNFetchBlob.fs.asset('subfolder/'))

I get

Error: ls error: failed to list path RNFetchBlob-file://bundle-assets://subfolder/ for it is not exist or it is not a folder at http://localhost:8081/index.android.b...

At least the assets folder should exist? How do I access the files in assets? Is there a way to do it without react-native-fetch-blob by simply passing a Path?

Share Improve this question asked Nov 20, 2017 at 11:22 four-eyesfour-eyes 12.5k37 gold badges130 silver badges255 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 2

react-native-fs package has that capability from the looks of it. haven't used it. wish react-native-fetch-blob supported it, but nothing in their docs.

https://github./itinance/react-native-fs#readdirassetsdirpath-string-promisereaddiritem

发布评论

评论列表(0)

  1. 暂无评论