Skip to content

Commit 2137827

Browse files
committed
fix: Correct psalm linter findings
Signed-off-by: oli-ver <oli-ver@users.noreply.github.com>
1 parent d9f5d71 commit 2137827

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/Controller/NotesApiController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,11 @@ public function getAttachment(int $noteid, string $path): Http\Response {
281281
$noteid,
282282
$path
283283
);
284-
$response = new StreamResponse($targetimage->fopen('rb'));
284+
$fileHandle = $targetimage->fopen('rb');
285+
if ($fileHandle === false) {
286+
throw new \Exception('Could not open file');
287+
}
288+
$response = new StreamResponse($fileHandle);
285289
$response->addHeader('Content-Disposition', 'attachment; filename="' . rawurldecode($targetimage->getName()) . '"');
286290
$response->addHeader('Content-Type', $this->mimeTypeDetector->getSecureMimeType($targetimage->getMimeType()));
287291
$response->addHeader('Cache-Control', 'public, max-age=604800');
@@ -299,7 +303,7 @@ public function getAttachment(int $noteid, string $path): Http\Response {
299303
*/
300304
public function uploadFile(int $noteid): JSONResponse {
301305
$file = $this->request->getUploadedFile('file');
302-
return $this->helper->handleErrorResponse(function () use ($noteid, $file) {
306+
return $this->helper->handleErrorResponse(function () use ($noteid, $file): array {
303307
return $this->service->createImage(
304308
$this->helper->getUID(),
305309
$noteid,

0 commit comments

Comments
 (0)