From b7c6dc7712fd4f78b4402fc825af7086c4faa50e 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 c6bcfe0047a..7d919e85c7b 100644 --- a/src/components/Editor/MediaHandler.vue +++ b/src/components/Editor/MediaHandler.vue @@ -110,8 +110,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 @@ -128,8 +128,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 @@ -156,8 +156,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 7a29b7b26ff118b75b69f2e5f4f820d42c3db93f 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 94eb1cde5c9..7b6f3337ca2 100644 --- a/lib/Controller/AttachmentController.php +++ b/lib/Controller/AttachmentController.php @@ -109,7 +109,7 @@ public function insertAttachmentFile(string $filePath): DataResponse { #[NoAdminRequired] #[PublicPage] #[RequireDocumentSession] - public function uploadAttachment(string $shareToken = ''): DataResponse { + public function uploadAttachment(string $token = ''): DataResponse { $documentId = $this->getSession()->getDocumentId(); try { @@ -120,8 +120,8 @@ public function uploadAttachment(string $shareToken = ''): 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 11f6fb3fb5d..45ff771b69b 100644 --- a/src/services/SessionApi.js +++ b/src/services/SessionApi.js @@ -147,7 +147,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',