前端基于远程二级制流下载文件的时候需要注意的前端需要在axios拦截器里面设置responseTypelei'x
config.responseType = "blob"
后端需要注意的是在设置Content-Disposition
的时候后面要加上下面这条,否则返回的res.headers就获取不到Content-Disposition
节点
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
// 清空输出流
response.setContentType("application/force-download");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(downFileName,"utf-8"));
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有