base64或者blob路径图片转File上传
objectURLToBlob(url) {
return new Promise(resolve => {
const http = new XMLHttpRequest()
http.open('GET', url, true)
http.responseType = 'blob'
http.onload = function(e) {
if (this.status == 200 || this.status === 0) {
resolve(this.response)
}
}
http.send()
})
},
async setCos() {
let imgObj= await this.objectURLToBlob(this.imageBase64), //base64 || blob
let imageBase64File = new File([imgObj], '', {
type: imgObj.type
})
// 上传图片到服务器....
},
小白一个,学不动回家喂猪