【问题标题】:React Native: Is there any way to check if the file exists in android_asset folder or not?React Native:有没有办法检查文件是否存在于 android_asset 文件夹中?
【发布时间】:2017-04-18 11:33:39
【问题描述】:

我需要像这样检查文件夹中的文件是否存在:

file:///android_asset/contents/my.html

我尝试过使用 react-native-filesystem 插件

componentWillMount () {
    async function checkIfFileExists() {
      const fileExists = await FileSystem.fileExists('file:///android_asset/contents/my.html')
      console.log(`file exists: ${fileExists}`)
    }
}

我确定 my.html 文件在那里,但我在 fileExists 中得到错误。 有人知道如何正确检查吗?

【问题讨论】:

  • 我认为 react native 与此无关。你说什么。

标签: javascript android react-native


【解决方案1】:

尝试使用react-native-fs

看起来他们有你正在寻找的功能:https://github.com/johanneslumpe/react-native-fs#existsassetsfilepath-string-promiseboolean

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-22
    • 1970-01-01
    • 1970-01-01
    • 2010-10-26
    • 1970-01-01
    • 2011-06-03
    相关资源
    最近更新 更多