标签:sda 需要 数据库 tee document ref 下载文件 bst result
使用element UI的upload组件
1 handleChange (file, fileList) { 2 let _this = this 3 if (this.formdata.printMode !== ‘Bartender‘) return 4 this.formdata.remark = file.name 5 let reader = new FileReader() 6 reader.readAsDataURL(file.raw) 7 reader.onload = function () { 8 _this.fileList = fileList 9 _this.bartenderstring = reader.result.substring(reader.result.indexOf(‘base64‘) + ‘base64,‘.length) 10 } 11 }, 12 decode (base64) { 13 let decode = window.atob(base64) 14 var len = decode.length 15 var bytes = new Uint8Array(len) 16 for (var i = 0; i < len; i++) { 17 bytes[i] = decode.charCodeAt(i) 18 } 19 // let str = decodeURI(decode) 20 return bytes 21 }, 22 handlePreview (file) { 23 try { 24 let content = this.decode(this.bartenderstring) 25 const blob = new Blob([content]) 26 let a = document.createElement(‘a‘); 27 a.download = file.name + ‘.btw‘; 28 a.href = URL.createObjectURL(blob); 29 let event = new MouseEvent(‘click‘); 30 a.dispatchEvent(event); 31 } catch (e) { 32 console.log(e) 33 } 34 }
Bartender文件.btw(ANSI)进行base64加密存进数据库,下载文件时需要进行atob解码在转成bytes字节后,new Blob才能得到ANSI编码的文本
标签:sda 需要 数据库 tee document ref 下载文件 bst result
原文地址:https://www.cnblogs.com/xuesen1995/p/14578310.html