fix(attachments): generate proper urls to dav service

Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
This commit is contained in:
Richard Steinmetz 2023-03-03 10:17:57 +01:00
parent 2f5f61db4f
commit ba047076d1
No known key found for this signature in database
GPG Key ID: 27137D9E7D273FB2
1 changed files with 5 additions and 5 deletions

View File

@ -21,7 +21,7 @@
*/ */
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router' import { generateOcsUrl, generateRemoteUrl } from '@nextcloud/router'
import { showError, showSuccess } from '@nextcloud/dialogs' import { showError, showSuccess } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n' import { translate as t } from '@nextcloud/l10n'
@ -84,10 +84,10 @@ const shareFileWith = async function(path, sharedWith, permissions = 17) {
} }
const createFolder = async function(folderName, userId) { const createFolder = async function(folderName, userId) {
const url = `/remote.php/dav/files/${userId}/${folderName}` const url = generateRemoteUrl(`dav/files/${userId}/${folderName}`)
await axios({ await axios({
method: 'MKCOL', method: 'MKCOL',
url: url.replace('//', '/'), url,
}).catch(e => { }).catch(e => {
if (e.response.status !== 405) { if (e.response.status !== 405) {
showError(t('calendar', 'Error creating a folder {folder}', { showError(t('calendar', 'Error creating a folder {folder}', {
@ -110,7 +110,7 @@ const uploadLocalAttachment = async function(folder, event, dav, componentAttach
fileName: file.name, fileName: file.name,
})) }))
} else { } else {
const url = `/remote.php/dav/files/${dav.userId}/${folder}/${file.name}` const url = generateRemoteUrl(`dav/files/${dav.userId}/${folder}/${file.name}`)
const res = axios.put(url, file).then(resp => { const res = axios.put(url, file).then(resp => {
const data = { const data = {
fileName: file.name, fileName: file.name,
@ -141,7 +141,7 @@ const uploadLocalAttachment = async function(folder, event, dav, componentAttach
// TODO is shared or not @share-types@ // TODO is shared or not @share-types@
const getFileInfo = async function(path, dav) { const getFileInfo = async function(path, dav) {
const url = `/remote.php/dav/files/${dav.userId}/${path}` const url = generateRemoteUrl(`dav/files/${dav.userId}/${path}`)
const res = await axios({ const res = await axios({
method: 'PROPFIND', method: 'PROPFIND',
url, url,