当前位置:网站首页>JS根据二进制数据下载文件
JS根据二进制数据下载文件
2022-07-13 17:36:00 【Jason秀啊】
逻辑简单,直接上代码
var xhr = new XMLHttpRequest()
xhr.open('get', '${ctx!}/admin/v1/licence/' + id)
xhr.responseType = "blob" // 设置响应数据类型为blob, 不设置会出现下载的文件比源文件更大
xhr.send()
xhr.onload = function() {
var blob = new Blob([this.response], {
type: this.responseType }); // ArrayBuffer , mime类型
// console.log(this.response.length, blob.size)
var a = document.createElement('a');
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = 'license.lic';
a.click();
}

边栏推荐
- 2022暑期实践(第一周)
- JS中的JSON(推出对象深拷贝)
- [Tensorflow2] 梯度反转层(GRL)与域对抗训练神经网络(DANN)的实现
- c语言中的输入输出函数之scanf函数
- Range installation and attacker configuration for penetration testing
- Solve the problem of unable to load authentication plugin 'caching' when idea2020 connects to MySQL 8_ sha2_ Password 'exception
- 命令行客户端的使用
- fastadmin的二次开发教程【简单搭建、多表格问题,API开发】
- Array changes, but the view cannot be updated (reason and thinking)
- 2022暑期实践(PowerDesigner教程学习记录)(第一周)
猜你喜欢
![[a little knowledge] AQS](/img/17/9b5709ddf6a1212934ceb637ddd81b.png)
[a little knowledge] AQS

2022暑期实践(PowerDesigner教程学习记录)(第一周)

Ardunio -- interaction between touch sensor and light -- judge whether the light is on according to the touch screen
![随机信号分析第2版 [赵淑清郑薇编著] (部分)课后作业答案(自己写的)](/img/13/edd5af20fb9a9514339d8ae21eed71.jpg)
随机信号分析第2版 [赵淑清郑薇编著] (部分)课后作业答案(自己写的)

ES6--数组

keil报错: ERROR 118 (ERRONEOUS REFERENCE TO EXTERNAL VARIABLES) 解决方案及原因

c语言中的输入输出函数之scanf函数

基于ssm项目中pagehelper分页插件的使用(简单易上手)

41.js--闭包

36.js--原型链2--(笔试题为主)
随机推荐
(cvpr-2022) Lagrangian motion analysis and perspective embedding for improved gait recognition
Use of command line client
centos7网络配置以及docker安装,mysql镜像的拉取以及docker的基础命令
【Tensorflow2】AttributeError: ‘Tensor‘ object has no attribute ‘numpy‘ 解决 (tf.py_function)
2022暑期实践(第一周)
CONDA based operation record of starting a tensorflow GPU (2.6.0) environment on win10 from scratch (2022.07)
Micro service mode: sidecar
C语言:通过结构体实现通讯录的简易功能
[hero planet July training leetcode problem solving daily] day 13 two-way linked list
ES6新增的模块化
蓝桥杯:单片机组第十三届省赛第二场
类加载器+反射+Properties
c语言中的输入输出函数之printf函数
Design and implementation of an eight bit compensator based on logisim
ES6--模块化
随机信号分析第2版 [赵淑清郑薇编著] (部分)课后作业答案(自己写的)
藍橋杯單片機第13届省賽題
Kubernetes入坑篇
Array changes, but the view cannot be updated (reason and thinking)
【黄啊码】MySQL入门—2、使用数据定义语言(DDL)操作数据库