在 React Native 中查看保存在缓存中的图像

pla*_*zin 5 react-native

我当前正在尝试从模块打开保存在缓存中的图像react-native-camera。根据这个来自React Native 应用程序的 Open android Gallery App,他们在传递content://url 而不是file://url 时设法做到了这一点,但经过一些研究,我找不到任何有关将文件 uri 转换为内容的内容 - 只有相反。我可以通过以下方式获取图像文件路径:

import RNFS from 'react-native-fs'
import { Linking } from 'react-native'

RNFS.readDir(RNFS.CachesDirectoryPath)
.then(arr => RNFS.readDir(arr[0].path)) // The Camera directory
.then(arr => arr.forEach(item => {
    const contentURI = somehowConvertPathToContentURI(item.path)

    Linking.canOpenURL(contentURI)
    .then(able => able ? Linking.openURL(contentURI) : console.log('No application available'))
    .catch(console.log)
}))
.catch(console.log)
Run Code Online (Sandbox Code Playgroud)

记录的路径将是/data/user/0/com.myapp/cache/Camera/ad8db2ca-4739-47cc-b18d-c5147c8c26e0.jpg. 在前面添加file://会给我文件uri,怎么样content://

作为旁注,如果我读取图像并将其转换为 Base64 react-native-fs,然后将 Base64 提供给 React-Native 的<Image>组件,我就可以直接显示图像 - 但我想使用图库应用程序打开该应用程序