Expo FileSystem-显示图像

时间:2019-11-05 21:27:57

标签: javascript image react-native expo

我很难理解有关图像的Expo FileSystem文档。我正在从FireBase抓取以文件扩展名file:///var/mobile/Containers/Data/Application/F1234555C/Library/Caches/ExponentExperienceData/%2540anonymous%252Fexmulti-55555a/ImagePicker/9D123456789.jpg存储的图片。

似乎我需要通过FileSystem.documentDirectory存储每个图像,然后通过FileSystem.getInfoAsync(fileUri, options)将它们再次拉出。然后,我可以像这样将返回的响应输入到Image源中:

<Image style={{flex:1, height: undefined, width: undefined}} resizeMode="cover" source={{uri: returnedFileSystemData}} />

我返回的响应不是一个适当的uri字符串,这导致我提出问题1)FileSystem.documentDirectory实际发生了什么,这甚至是将图像文件传递到源标签的正确方法吗?

https://docs.expo.io/versions/latest/sdk/filesystem/

代码(可能有语法错误-只需手写一下即可大致了解我在做什么):

firebase.database().ref('/Users/' + userId).once('value').then(function(snapshot) {
        var pictures = (snapshot.val() && snapshot.val().pictures);
        setPictures(pictures);
        FileSystem.documentDirectory + pictures;
        Object.keys(pictures).map(function(key) {
            //I have tried looping through the pictures array and adding each file to the documentDirectory as well
        }

       ....
       <View style={[styles.child]}>
           <Image style={{flex:1, height: undefined, width: undefined}} resizeMode="cover" source={{uri: FileSystem.getInfoAsync(pictures[0])}} />

0 个答案:

没有答案