详细问题描述
H5开发中使用到uni.chooseVideo与uni.chooseImage,想通过FileReader -> readAsDataURL 得到Base64格式并传给百度AI做H5实名认证。 uni.chooseImage的问题 已经通过插件解决。 而现在剩下的uni.chooseVideo找了很久也没找到解决备案
重现步骤
uni.chooseVideo({
sourceType: ['camera'],
camera: 'front',
maxDuration: 10,
success: res => {
console.log(res.tempFilePath)
let reader = new FileReader()
reader.onload = (e) => {
var videoSrc = e.target.result
}
let rs = reader.readAsDataURL(res.tempFilePath)
}
})
},
[结果]
Uncaught (in promise) TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.
[期望]
期望解决这个问题,让uni.chooseVideo与uni.chooseImage得到的blob文件地址 可以正常用FileReader操作。
如不能解决,起码给个解决方案
IDE运行环境说明
HBuilder 2.3.7.20191024
win10
uni-app运行环境说明
h5
cli创建
联系方式
[QQ] 827887
2 个回复
8***@qq.com (作者) - 自由工作比上班赚的多
var xhr = new XMLHttpRequest()
xhr.responseType = 'blob'
//如果是指xhr.responseType = 'blob',将返回一个Blob对象,而不是文本;
//xhr.responseType = 'blob';
xhr.onload = () => {
//alert(xhr.responseText)
1***@qq.com
想问一下uni.chooseImage这个是使用了哪个插件解决的呀