projects
/
Pman.Core
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fa8f544
)
Pman.Download.js
author
Alan Knowles
<alan@roojs.com>
Wed, 14 Aug 2019 08:12:15 +0000
(16:12 +0800)
committer
Alan Knowles
<alan@roojs.com>
Wed, 14 Aug 2019 08:12:15 +0000
(16:12 +0800)
Pman.Download.js
patch
|
blob
|
history
diff --git
a/Pman.Download.js
b/Pman.Download.js
index
5111f27
..
08b83a6
100644
(file)
--- a/
Pman.Download.js
+++ b/
Pman.Download.js
@@
-135,8
+135,14
@@
Pman.Download = function(cfg)
{
if (req.status == 200) {
Roo.log(ev);
{
if (req.status == 200) {
Roo.log(ev);
- var headers = req.getAllResponseHeaders();
- Roo.log(req.getAllResponseHeaders())
+ var cd = req.getResponseHeader('Content-Disposition');
+
+ var filename = '';
+ var matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(cd);
+ if (matches != null && matches[1]) {
+ filename = matches[1].replace(/['"]/g, '');
+ }
+
var blob = new Blob([this.response], {type: req.responseType });
var a = document.createElement("a");
var blob = new Blob([this.response], {type: req.responseType });
var a = document.createElement("a");
@@
-144,7
+150,7
@@
Pman.Download = function(cfg)
document.body.appendChild(a);
var url = window.URL.createObjectURL(blob);
a.href = url;
document.body.appendChild(a);
var url = window.URL.createObjectURL(blob);
a.href = url;
- a.download =
'myFile.pdf'
;
+ a.download =
filename
;
a.click();
//release the reference to the file by revoking the Object URL
window.URL.revokeObjectURL(url);
a.click();
//release the reference to the file by revoking the Object URL
window.URL.revokeObjectURL(url);