POST 发送请求,下载文件流文件
// 程序包下载
programDown(filePath, productKey, versionNum) {
this.$axios({
method: "post",
// 后台请求接口地址
url: this.$axios.adUserUrl("/productVersion/downloadIssue"),
headers: {
"Content-Type": "application/json; charset=utf-8",
},
// 关键部分
responseType: "blob",
// 请求参数
data: this.$axios.adornData({
filePath: filePath,
productKey: productKey,
versionNum: versionNum,
}),
})
.then((response) => {
// 将文件流转成blob形式
let blob = new Blob([response.data], { type: "text/plain" });
// 取出文件名
let filename = decodeURI(
response.headers["content-disposition"].split("filename=")[1]
);
if (window.navigator.msSaveOrOpenBlob) {
// 兼容IE10
navigator.msSaveBlob(blob, filename);
} else {
// 创建一个