X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use anchor element to trigger download
  • Loading branch information
LukasHirt authored and kulmann committed Jul 27, 2020
commit fe060d39cc1f8cd9e617085ddaf605cc216fd7e4
16 changes: 15 additions & 1 deletion src/plugins/phoenix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
X Tutup