文件下载

文件流形式下载文件

 downFile (row) { //${API.attachment}/download
      let url = null;
      if (row.url.includes('group')) {
        url = row.url;
      } else {
        url = decode(row.url);
      }
      AttachmentManageService.downFile(url).then(respones => {
        console.log(respones)
        var blob = new Blob([respones.data], { type: 'application/actet-stream;charset=utf-8' })
        var downloadElement = document.createElement('a');
        var href = window.URL.createObjectURL(blob); //创建下载的链接
        downloadElement.href = href;
        downloadElement.download = row.originalName; //下载后文件名
        document.body.appendChild(downloadElement);
        downloadElement.click(); //点击下载
        document.body.removeChild(downloadElement); //下载完成移除元素
        window.URL.revokeObjectURL(href); //释放掉blob对象
      })
    },
  downFile(url) {
    //window.open(`${API.attachment}/download?url=${data}`)
      return request({
     // headers:{responseType: 'arraybuffer'},
      url: `${API.attachment}/download?file=${url}`,
      method: 'post',
          data: {},
          responseType: 'arraybuffer'
    })
  }