我正在尝试使用客户端应用程序中的内存上传图像
反应本机图像选择器@^0.26.4
执行以下示例片段后,我以意想不到的方式得到了响应。
ImagePicker.showImagePicker(options, response => {
console.log("Response = ", response)
if (response.didCancel) {
console.log("User cancelled image picker")
} else if (response.error) {
console.log("ImagePicker Error: ", response.error)
} else if (response.customButton) {
console.log("User tapped custom button: ", response.customButton)
} else {
const source = { uri: response.uri }
// RNGRP.getRealPathFromURI(response.uri).then(filePath => {
// uploadImageToS3(filePath, "dinesh")
// console.log(filePath)
// })
// You can also display the image using data:
// let source = { uri: 'data:image/jpeg;base64,' + response.data };
this.setState({
avatarSource: source
})
}
RESPONSE
附加信息
- React Native 版本:~0.46.1
- 反应:16.0.0-alpha.12
- 平台:【Android 5.1及以上】
- 开发操作系统:[Windows 7 Professional]
- 开发工具:[ Android Studio 版本 2.3.2、Android SDK 23]
将此代码添加到您的AndroidManifest.xml
:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
根据 Jaffar Raza 和 szskdgi 的建议编辑了此内容
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)