afterRead(file){
console.log(file,'0000')
this.face = [];
let canvas = document.createElement('canvas') // 创建Canvas对象(画布)
let context = canvas.getContext('2d')
let img = new Image()
img.src = file.content // 指定图片的DataURL(图片的base64编码数据)
img.onload = () => {
canvas.width = img.width/10
canvas.height = img.height/10
context.drawImage(img, 0, 0, img.width/10, img.height/10)
file.content = canvas.toDataURL(file.file.type, 0.92) // 0.92为默认压缩质量
console.log(file,file.content,'4444444')
let files = this.dataURLtoFile(file.content, file.file.name)
console.log(files,'33333')
this.uploadToqiniu(files,this.face);
}
},
dataURLtoFile (dataurl, filename) { // 将base64转换为file文件
let arr = dataurl.split(',')
let mime = arr[0].match(/:(.*?);/)[1]
let bstr = atob(arr[1])
let n = bstr.length
let u8arr = new Uint8Array(n)
while (n--) {
u8arr[n] = bstr.charCodeAt(n)
}
return new File([u8arr], filename, {type: mime})
},