前言:
此时姐妹们对“jqueryzsignjs下载”都比较注意,同学们都想要了解一些“jqueryzsignjs下载”的相关内容。那么小编在网上网罗了一些关于“jqueryzsignjs下载””的相关文章,希望兄弟们能喜欢,各位老铁们快快来学习一下吧!1.图片,文件批量下载(不跨域的情况下)
import JSZip from 'jszip';import {saveAs} from 'file-saver';import axios from 'axios'const getFile = url => {return new Promise((resolve, reject) => {let obj = {method: 'get',url,// responseType: 'blob'responseType: 'arraybuffer'}axios(obj).then(data => {resolve(data.data)}).catch(error => {reject(error.toString())})})}const fileList = [';,';]const zip = new JSZip()const cache = {}const promises = []fileList.forEach(item => {const promise = getFile(item).then(data => {const arr_name = item.split('/') // 下载文件, 并存成ArrayBuffer对象const file_name = arr_name[arr_name.length - 1] // 获取文件名zip.file(file_name, data, {binary: true}) // 逐个添加文件cache[file_name] = dataconsole.log(cache)})promises.push(promise)})Promise.all(promises).then(() => {zip.generateAsync({type: 'blob'}).then(content => {console.log(content)// 生成二进制流saveAs(content, '文件下载.zip') // 利用file-saver保存文件 自定义文件名})})2.base64图片下载
var zip = new JSZip();zip.file("Hello.txt", "Hello World\n");// zip.file(";);var img = zip.folder("images");var imageData = 'iVBORw0KGgoAAAANSUhEUgAAArMAAABmCAYAAADYixmuAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABllSURBVHhe7Z3dbhtHloDnBfYB9hH2Zh9AM/bsYpF41pISh4RiXcQ/Ska2ZTo3a2ORwAGp3CUOfCUmxgJRJEAw9QyhHq62q7pP96nqKrKpXxb1XXwwu/rUqaqWAH86LLL+8i//dtcAAAAAAOTGv/77HfOXv/39Pw0AAAAAQG789c7fkVkAAAAAyBNkFgAAAACyJTuZXf/sc/P8+XMzGAw6YWNtn1guAAAAAMib7GT2+fMXZuPBF+a//vt+J2ys7RPLBQAAAAB5k53M2mprTFo1m72+ebq7W1/bPrFcOfCPp2/MaPCl6Q9G7t/o/Tc75h93/6N1bxWw6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o+RR/Jq6lFWuWPEas0elI3Q17DayubUuHUhIIZ9usPrFAWkujmYcduBNNixVdyJWVWVXOln2uPCmslszPmG+Zv8rXnBwAAAHmQ9TaD7wpxtQL7++Gh+/dg/Kur2GqRtcRk1iKVViulUjltpDKQ2EEhuVLJrbYY1H20DF+SzMb6NHFzZDZRaZTKqa6guvg5Mtv1Gw8aKQwkdqvIV+Uoc6vtCHqsQDbPK7Op+aZlNv68AAAAYPnJWmY/Vd9ccHJyYnrb257ECimZdRI6GRfS2kilxclt0SZbAOS6ltdANt3WhJTMVtsJ9PXQVVhnyGzQx7I3juePEcpe3e7E8Y17+1/fk3Zpc7JbC6bN5Qtgv3ieKfGzfW1+kWW5ruU1kE1/rEBmg7Ht9RNXYZ0hszPmm5RZJdS6HQAAAJaf7D8Atv3osavMvnj1rdeuScpsJYb6g1euvaq81gLqrkPxVB/OKkRTKrP2vmw/qPfkVvlcWy29aZnVc5AxGhmeL7MW/W0GgshcrHJppbJ+S754Xu1Krf+BLd1XI7G1gAaiLHNIjSXzkDnqsX3BjsusnoOMUc8lJbNWsFWlGgAAAPIhe5ntQkpmVxkndIm326EhFGEAAADIi+xkdlWOs70O3Fv4VBxnor9ODAAAAPIjO5ld/+zzQk6fu2prF2ys7RPLBQAAAAB5k53MAgAAAAAIyCwAAAAAZAsyCwAAAADZgswCAAAAQLb89c7fzf8DnEEpgoQiOSwAAAAASUVORK5CYII='img.file("smile.png", imageData, {base64: true});zip.generateAsync({type: "blob"}).then(function (content) {// see FileSaver.jssaveAs(content, "example.zip");});3.前后端分离,导致的图片,文件跨域情况下,批量下载图片,文件的方案
1.前端:
async downFile(e) {let filePath = nullfilePath = e.document_urllet a = document.createElement("a");a.href = filePath;a.setAttribute("download", e.document_name);a.click();},
2.通过nginx服务器做反向代理到前端项目的服务器,并配置图片,文件的反向代理,如下:
nginx.conf文件:
server {location /upload/ {proxy_pass ;}}
这样就实现了,a标签在同域正常下载资源
版权声明:
本站文章均来自互联网搜集,如有侵犯您的权益,请联系我们删除,谢谢。
标签: #jqueryzsignjs下载