前端下载文件流

const sessionData: any = sessionStorage.getItem("token");
  const tokenHead: any = sessionStorage.getItem("headerType");
  let params = {
    fileInfoId: row.fileInfoId,
    id: row.id,
    name: row.name,
  };
  axios({
    method: "post",
    url: apiConstatns.URL.META_BASE.FILE_DOWNDILE,
    data: params,
    responseType: "blob",
    headers: { Authorization: tokenHead + sessionData },
  }).then((res: any) => {
    let blob = new Blob([res.data], { type: "application/octet-stream" });
    const downloadElement = document.createElement("a");
    const headers = res.headers;
    const fileName = filterDate(row.createTime) + row.name;
    downloadElement.download = fileName;
    downloadElement.href = URL.createObjectURL(blob);
    document.body.appendChild(downloadElement);
    downloadElement.click();
    document.body.removeChild(downloadElement);
  });

相关推荐

  1. 前端下载文件

    2024-05-15 15:42:07       31 阅读
  2. 前端实现文件下载

    2024-05-15 15:42:07       30 阅读
  3. 前端下载导出文件,excel/word/pdf/zip等

    2024-05-15 15:42:07       64 阅读
  4. 前端下载文件 出现乱码 解决方案

    2024-05-15 15:42:07       23 阅读
  5. 前端几种下载文件的方式(url方式和文件方式)

    2024-05-15 15:42:07       45 阅读
  6. 前端下载文件方法

    2024-05-15 15:42:07       56 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-15 15:42:07       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-15 15:42:07       100 阅读
  3. 在Django里面运行非项目文件

    2024-05-15 15:42:07       82 阅读
  4. Python语言-面向对象

    2024-05-15 15:42:07       91 阅读

热门阅读

  1. 5.14 力扣每日一题 贪心

    2024-05-15 15:42:07       42 阅读
  2. dom驱动和数据驱动的理解

    2024-05-15 15:42:07       38 阅读
  3. Vue学习v-on

    2024-05-15 15:42:07       35 阅读
  4. 连接和断开与服务器的连接

    2024-05-15 15:42:07       28 阅读
  5. uniapp实现拖拽排序+滑动删除功能

    2024-05-15 15:42:07       31 阅读
  6. SQL Server BULK INSERT

    2024-05-15 15:42:07       38 阅读
  7. 常见网络攻击及解决方案

    2024-05-15 15:42:07       33 阅读
  8. 2024年广东省助理工程师职称评审指南!

    2024-05-15 15:42:07       38 阅读
  9. 【数据库】银行转账并发问题

    2024-05-15 15:42:07       33 阅读
  10. 学习MySQL(一):了解数据库

    2024-05-15 15:42:07       34 阅读