From f284c434424b55029de8db7c4f2b561d78f665ac Mon Sep 17 00:00:00 2001 From: Lukas Hirt Date: Tue, 21 Jul 2020 13:46:38 +0200 Subject: [PATCH] Use anchor element to trigger download --- src/plugins/phoenix.js | 16 +++++++++++++++- yarn.lock | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/plugins/phoenix.js b/src/plugins/phoenix.js index 262e3838b9f..4b5d376e7c3 100644 --- a/src/plugins/phoenix.js +++ b/src/plugins/phoenix.js @@ -31,7 +31,21 @@ export default { headers: { Authorization: 'Bearer ' + this.getToken } }).then(res => { if (res.status === 200) { - window.location = signedUrl + const a = document.createElement('a') + a.style.display = 'none' + document.body.appendChild(a) + + a.href = signedUrl + + console.log(file) + // Use download attribute to set desired file name + a.setAttribute('download', file.name) + + // Trigger the download by simulating click + a.click() + + // Cleanup + document.body.removeChild(a) } else if (res.status === 404) { this.showMessage({ title: this.$gettext('Download failed'), diff --git a/yarn.lock b/yarn.lock index 3fcd1ec3f4f..9e074907007 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2917,9 +2917,9 @@ data-uri-to-buffer@1: resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-1.2.0.tgz#77163ea9c20d8641b4707e8f18abdf9a78f34835" integrity sha512-vKQ9DTQPN1FLYiiEEOQ6IBGFqvjCa5rSK3cWMy/Nespm5d/x3dGFT9UBZnkLxCwua/IXBi2TYnwTEpsOvhC4UQ== -"davclient.js@git+https://github.com/owncloud/davclient.js.git": +"davclient.js@https://github.com/owncloud/davclient.js.git": version "0.2.1" - resolved "git+https://github.com/owncloud/davclient.js.git#bf19f590451b3c0658913568053ec7f300f7dfc1" + resolved "https://github.com/owncloud/davclient.js.git#bf19f590451b3c0658913568053ec7f300f7dfc1" de-indent@^1.0.2: version "1.0.2"