Skip to content

Commit 9468edd

Browse files
committed
feat: use Json view and remove .json endpoints
1 parent 1c22b09 commit 9468edd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ For files with `secureDownload: true` or when you need controlled access:
413413
**Get file token:**
414414

415415
```
416-
POST /attachment/download/get-file-token.json
416+
POST /attachment/download/get-file-token
417417
Body: { "file": "<attachment_id>" }
418418
Response: { "token": "<jwt_token>" }
419419
```
@@ -433,7 +433,7 @@ GET /attachment/download/stream/<token>
433433
**Get ZIP token for multiple files:**
434434

435435
```
436-
POST /attachment/download/get-zip-token.json
436+
POST /attachment/download/get-zip-token
437437
Body: { "files": ["<id1>", "<id2>", ...] }
438438
Response: { "token": "<jwt_token>" }
439439
```

src/Controller/DownloadController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public function getZipToken()
1414
if (!$this->getRequest()->is('post')) throw new BadRequestException('Post Needed');
1515
if(empty($this->getRequest()->getData('files'))) $this->set('token', '');
1616
else $this->set('token', (new Token)->encode(['files' => $this->getRequest()->getData('files')]));
17+
$this->viewBuilder()->setClassName('Json');
1718
$this->viewBuilder()->setOption('serialize', ['token']);
1819
}
1920
// (new Token)->encode(['files' => [$attachment1->id, $attachment2->id]])
@@ -39,6 +40,7 @@ public function getFileToken()
3940
if (!$this->getRequest()->is('post')) throw new BadRequestException('Post Needed');
4041
if(empty($this->getRequest()->getData('file'))) $this->set('token', '');
4142
else $this->set('token', (new Token)->encode(['file' => $this->getRequest()->getData('file')]));
43+
$this->viewBuilder()->setClassName('Json');
4244
$this->viewBuilder()->setOption('serialize', ['token']);
4345
}
4446
// (new Token)->encode(['file' => $attachment->id])

0 commit comments

Comments
 (0)