React Native iOS read image from apps Documents folder -


i have download images ios apps local file system , read them back.

on simulator can see file system of app directories

/library/developer/coresimulator/devices/[uuid]/data/containers/data/application/[uuid]/  /documents /library /tmp 

to try out copied foo.png /documents folder , tried

<image source={{uri: "file://documents/foo.png"}} style={{width:100, height:100}}/> 

this not work, idea whats way this.

this took me ages... better info have been 5 minutes!

i use react-native-fs directories (which works ios , android):

var rnfs = require('react-native-fs'); 

rnfs.documentdirectorypath returns '/var/mobile/containers/data/application/15ac1cc6-8cff-48f0-affd-949368383acb/documents' on ios

my image element looks like:

<image           style={{width:100, height:100}}           source={{uri: 'file://' + rnfs.documentdirectorypath + '/myawesomesubdir/my.png', scale:1}}         />  

my problem did not set width , height first, not needed urls or paths assets. when using base64 uri width , heigth mandatory (that led me solution!).


Comments