Skip to content

Commit

Permalink
fix: public link download in authenticated context
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Feb 19, 2024
1 parent 6fca4f4 commit 0f5a501
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions packages/web-pkg/src/composables/download/useDownloadFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,27 @@ export const useDownloadFile = (options?: DownloadFileOptions) => {
const { owncloudSdk: client } = clientService
const isUserContext = store.getters['runtime/auth/isUserContextReady']

// construct the url and headers
let url
if (unref(isPublicLinkContext)) {
url = file.downloadURL
} else {
if (version === null) {
url = `${client.helpers._davPath}${file.webDavPath}`
} else {
url = client.fileVersions.getFileVersionUrl(file.fileId, version)
// public links have a pre-signed download url
if (file.downloadURL) {
try {
triggerDownloadWithFilename(file.downloadURL, file.name)
} catch (e) {
console.error(e)
store.dispatch('showErrorMessage', {
title: $gettext('Download failed'),
desc: $gettext('File could not be located'),
errors: [e]
})
}
return
}

// construct the download url
const url =
version === null
? `${client.helpers._davPath}${file.webDavPath}`
: client.fileVersions.getFileVersionUrl(file.fileId, version)

// download with signing enabled
if (isUserContext && unref(isUrlSigningEnabled)) {
const httpClient = clientService.httpAuthenticated
Expand Down

0 comments on commit 0f5a501

Please sign in to comment.