X Tutup
Skip to content

Commit f284c43

Browse files
committed
Use anchor element to trigger download
1 parent 56e4184 commit f284c43

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/plugins/phoenix.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,21 @@ export default {
3131
headers: { Authorization: 'Bearer ' + this.getToken }
3232
}).then(res => {
3333
if (res.status === 200) {
34-
window.location = signedUrl
34+
const a = document.createElement('a')
35+
a.style.display = 'none'
36+
document.body.appendChild(a)
37+
38+
a.href = signedUrl
39+
40+
console.log(file)
41+
// Use download attribute to set desired file name
42+
a.setAttribute('download', file.name)
43+
44+
// Trigger the download by simulating click
45+
a.click()
46+
47+
// Cleanup
48+
document.body.removeChild(a)
3549
} else if (res.status === 404) {
3650
this.showMessage({
3751
title: this.$gettext('Download failed'),

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,9 +2917,9 @@ data-uri-to-buffer@1:
29172917
resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-1.2.0.tgz#77163ea9c20d8641b4707e8f18abdf9a78f34835"
29182918
integrity sha512-vKQ9DTQPN1FLYiiEEOQ6IBGFqvjCa5rSK3cWMy/Nespm5d/x3dGFT9UBZnkLxCwua/IXBi2TYnwTEpsOvhC4UQ==
29192919

2920-
"davclient.js@git+https://github.com/owncloud/davclient.js.git":
2920+
"davclient.js@https://github.com/owncloud/davclient.js.git":
29212921
version "0.2.1"
2922-
resolved "git+https://github.com/owncloud/davclient.js.git#bf19f590451b3c0658913568053ec7f300f7dfc1"
2922+
resolved "https://github.com/owncloud/davclient.js.git#bf19f590451b3c0658913568053ec7f300f7dfc1"
29232923

29242924
de-indent@^1.0.2:
29252925
version "1.0.2"

0 commit comments

Comments
 (0)
X Tutup