我使用react-native-camera来捕获图像,并将它们保存在iOS设备的cameraRoll (CaptureTarget)中,在捕获时,我会获得以下形式的图像路径
"assets-library://asset/asset.JPG?id=8B55D3E5-11CE-439A-8FC6-D55EB1A88D7E&ext=JPG"如何使用此路径在image组件中显示图像(来自react-native)?
以前我是使用磁盘作为CaptureTarget选项,我能够显示该图像url图像组件,但现在的要求是保存图像在相机胶卷?
发布于 2017-04-10 20:55:05
我已经使用RNFetchBlob从“assets- base64 ://..”获取了资源库。url,我的捕获函数是
this.camera.capture()
.then((data) => {
// console.log(data);
RNFetchBlob.fs.readFile(data.path, 'base64')
.then((base64data) => {
let base64Image = `data:image/jpeg;base64,${base64data}`;
this.props.addImagesToUntagged(data.path);
})
})在此之后,我为用户提供了对此base64数据的一些应用内功能,最后,当我需要将此数据发送到s3服务器时,我使用axios和RNFetchBlob发送此data.following代码,从而为s3提供了签名的url。
axios.get(ENDPOINT_TO_GET_SIGNED_URL, {params:{'file-name': file.name,'file-type': file.type,"content-type": 'evidence'}})
.then(function (result) {
// console.log(result);
returnUrl = result.data.url;
var signedUrl = result.data.signedRequest;
return uploadFile(file,signedUrl)
})在我的uploadFile函数中,我通过以下代码上传图片
RNFetchBlob.fetch('PUT', signedUrl,
{'Content-Type' : file.type},
RNFetchBlob.wrap(file.uri)
)
.then(resolve)https://stackoverflow.com/questions/41950811
复制相似问题