Skip to content

Commit eac32b4

Browse files
committed
fix(attachments): Uploading of attachments from public shares
The session middleware expects the share token as param `token`. Fixes: #6206 Signed-off-by: Jonas <[email protected]>
1 parent 84de239 commit eac32b4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/Controller/AttachmentController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function insertAttachmentFile(string $filePath): DataResponse {
126126
#[NoAdminRequired]
127127
#[PublicPage]
128128
#[RequireDocumentSession]
129-
public function uploadAttachment(?string $shareToken = null): DataResponse {
129+
public function uploadAttachment(?string $token = null): DataResponse {
130130
$documentId = $this->getSession()->getDocumentId();
131131

132132
try {
@@ -137,8 +137,8 @@ public function uploadAttachment(?string $shareToken = null): DataResponse {
137137
throw new Exception('Could not read file');
138138
}
139139
$newFileName = $file['name'];
140-
if ($shareToken) {
141-
$uploadResult = $this->attachmentService->uploadAttachmentPublic($documentId, $newFileName, $newFileResource, $shareToken);
140+
if ($token) {
141+
$uploadResult = $this->attachmentService->uploadAttachmentPublic($documentId, $newFileName, $newFileResource, $token);
142142
} else {
143143
$userId = $this->getSession()->getUserId();
144144
$uploadResult = $this->attachmentService->uploadAttachment($documentId, $newFileName, $newFileResource, $userId);

src/services/SessionApi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export class Connection {
164164
+ '?documentId=' + encodeURIComponent(this.#document.id)
165165
+ '&sessionId=' + encodeURIComponent(this.#session.id)
166166
+ '&sessionToken=' + encodeURIComponent(this.#session.token)
167-
+ '&shareToken=' + encodeURIComponent(this.#options.shareToken || '')
167+
+ '&token=' + encodeURIComponent(this.#options.shareToken || '')
168168
return this.#post(url, formData, {
169169
headers: {
170170
'Content-Type': 'multipart/form-data',

0 commit comments

Comments
 (0)