From a8705a14bf181650d3a8376c225a6c67f472b244 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Wed, 14 Aug 2019 15:59:07 +0800 Subject: [PATCH] Pman.Download.js --- Pman.Download.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Pman.Download.js b/Pman.Download.js index be404385..9c023978 100644 --- a/Pman.Download.js +++ b/Pman.Download.js @@ -127,12 +127,26 @@ Pman.Download = function(cfg) } var req = new XMLHttpRequest(); + xhr.responseType = 'blob'; req.open(this.method, this.url); var _t = this; req.onload = function( ev ) { if (req.status == 200) { + Roo.log(ev); + var blob = new Blob([this.response], {type: req.responseType }); + + var a = document.createElement("a"); + a.style = "display: none"; + document.body.appendChild(a); + var url = window.URL.createObjectURL(blob); + a.href = url; + a.download = 'myFile.pdf'; + a.click(); + //release the reference to the file by revoking the Object URL + window.URL.revokeObjectURL(url); + _t.success ? _t.success(ev) : ''; } else { _t.failure ? _t.failure(ev) : ''; -- 2.39.2