From 84de239dc70146309b87ef49c0595646cf4dc3df Mon Sep 17 00:00:00 2001 From: Jonas Date: Wed, 14 Aug 2024 12:31:09 +0200 Subject: [PATCH 1/2] fix(MediaHandler): Show proper error message on upload failure Signed-off-by: Jonas --- src/components/Editor/MediaHandler.vue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/Editor/MediaHandler.vue b/src/components/Editor/MediaHandler.vue index 3affd10e8df..7bb82a0ca4f 100644 --- a/src/components/Editor/MediaHandler.vue +++ b/src/components/Editor/MediaHandler.vue @@ -127,8 +127,8 @@ export default { return Promise.all(uploadPromises) .catch(error => { - logger.error('Uploading multiple images failed', { error }) - showError(error?.response?.data?.error || error.message) + logger.error('Uploading multiple attachments failed', { error }) + showError(t('text', 'Uploading multiple attachments failed.')) }) .then(() => { this.state.isUploadingAttachments = false @@ -145,8 +145,8 @@ export default { ) }) .catch((error) => { - logger.error('Uploading image failed', { error }) - showError(error?.response?.data?.error) + logger.error('Uploading attachment failed', { error }) + showError(t('text', 'Uploading attachment failed.')) }) .then(() => { this.state.isUploadingAttachments = false @@ -173,8 +173,8 @@ export default { null, response.data?.dirname, ) }).catch((error) => { - logger.error('Failed to insert image path', { error }) - showError(error?.response?.data?.error || error.message) + logger.error('Failed to insert from Files', { error }) + showError(t('text', 'Failed to insert from Files')) }).then(() => { this.state.isUploadingAttachments = false }) From eac32b4b99776b3cc9e233d6d39b28936e27ae35 Mon Sep 17 00:00:00 2001 From: Jonas Date: Wed, 14 Aug 2024 16:50:16 +0200 Subject: [PATCH 2/2] fix(attachments): Uploading of attachments from public shares The session middleware expects the share token as param `token`. Fixes: #6206 Signed-off-by: Jonas --- lib/Controller/AttachmentController.php | 6 +++--- src/services/SessionApi.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Controller/AttachmentController.php b/lib/Controller/AttachmentController.php index 44a85aaf110..62a655be39c 100644 --- a/lib/Controller/AttachmentController.php +++ b/lib/Controller/AttachmentController.php @@ -126,7 +126,7 @@ public function insertAttachmentFile(string $filePath): DataResponse { #[NoAdminRequired] #[PublicPage] #[RequireDocumentSession] - public function uploadAttachment(?string $shareToken = null): DataResponse { + public function uploadAttachment(?string $token = null): DataResponse { $documentId = $this->getSession()->getDocumentId(); try { @@ -137,8 +137,8 @@ public function uploadAttachment(?string $shareToken = null): DataResponse { throw new Exception('Could not read file'); } $newFileName = $file['name']; - if ($shareToken) { - $uploadResult = $this->attachmentService->uploadAttachmentPublic($documentId, $newFileName, $newFileResource, $shareToken); + if ($token) { + $uploadResult = $this->attachmentService->uploadAttachmentPublic($documentId, $newFileName, $newFileResource, $token); } else { $userId = $this->getSession()->getUserId(); $uploadResult = $this->attachmentService->uploadAttachment($documentId, $newFileName, $newFileResource, $userId); diff --git a/src/services/SessionApi.js b/src/services/SessionApi.js index 4e596ba5adc..95d97d5ccc9 100644 --- a/src/services/SessionApi.js +++ b/src/services/SessionApi.js @@ -164,7 +164,7 @@ export class Connection { + '?documentId=' + encodeURIComponent(this.#document.id) + '&sessionId=' + encodeURIComponent(this.#session.id) + '&sessionToken=' + encodeURIComponent(this.#session.token) - + '&shareToken=' + encodeURIComponent(this.#options.shareToken || '') + + '&token=' + encodeURIComponent(this.#options.shareToken || '') return this.#post(url, formData, { headers: { 'Content-Type': 'multipart/form-data',