通过后端下载文件流
1 将文件放在静态目录下,然后通过axios进行请求 这里要注意请求的时候一定要设置 responseType:‘blob’ 然后通过js 的 Blob转换一下
axios({url:'/-app-/resource/abc.docx',responseType: 'blob',}).then(res => {
console.log('res----',res)
var blob= new Blob([res.data], {type : 'application/json, text/plain, */*'});
blob.name = '德玛西亚.docx'
blob.lastModifiedDate =new Date();
var formData = new FormData()
formData.append('file',blob)
formData.append('FileName', blob.name)
axios.post(url, formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
})
})