Sum*_*ois 5 javascript react-native redux-saga react-redux react-native-fs
我正在尝试使用react-native-fs和redux-saga使用URI读取图像文件:
file:///var/mobile/Containers/Data/Application/605FB6C0-869C-4128-883E-A59616933C64/Documents/images/52108C66-A087-4942-9DD4-22CBD0327089.jpg
下面是我在尝试读取图像文件时遇到错误的行:
const imageFile = yield call([RNFS, RNFS.readFile], logo.uri);
Run Code Online (Sandbox Code Playgroud)
以下是我收到的错误:
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
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我我做错了什么吗?
这就是我在 iOS 上处理 JPEG 文件的方式:
(...)
var RNFS = require('react-native-fs');
(...)
var uri = '{your file uri}'
var img = 'file:///' + (uri.replace('file://', '')); // Must do that for RNFS
RNFS.readFile(img, 'base64') // 'base64' to process binary format
.then((file) => {
console.log("Getting image");
console.log(file);
})
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7877 次 |
最近记录: |