React-native-fs: Not able read an image file

Created on 16 Jan 2018  路  2Comments  路  Source: itinance/react-native-fs

I am trying to read an image file using the URI using react-native-fs and redux-saga: file:///Users/sumanthjois/Library/Developer/CoreSimulato鈥57-919576574436/Documents/images/BA3C395C-B5FE-43C3-BC99-E2FDE2E3AA57.jpg

Below is the line where I am getting an error while trying to read the image file:

const imageFile = yield call([RNFS, RNFS.readFile], logo.uri);
Below is the error I am getting:

Error: Invalid UTF-8 detected
    at decodeSymbol (utf8.js:194)
    at Object.utf8decode [as decode] (utf8.js:206)
    at FS.common.js:150
    at tryCallOne (core.js:37)
    at core.js:123
    at JSTimers.js:301
    at _callTimer (JSTimers.js:154)
    at _callImmediatesPass (JSTimers.js:202)
    at Object.callImmediates (JSTimers.js:470)
    at MessageQueue.__callImmediates (MessageQueue.js:275)
    at MessageQueue.js:140


Most helpful comment

Try setting encoding to "base64".

All 2 comments

Try setting encoding to "base64".

Affirmitive! :) ... Encoded image data can be later on displayed in react-native like this:

<Image source={{uri: `data:image/png;base64,${encodedData}`}} />
Was this page helpful?
0 / 5 - 0 ratings