From 35d548383a9fcf0cc5ece87498952c27c011074d Mon Sep 17 00:00:00 2001 From: Matias De lellis Date: Wed, 18 Nov 2020 19:14:40 -0300 Subject: [PATCH] Dont upload rejected files --- lib/Controller/AttachmentApiController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Controller/AttachmentApiController.php b/lib/Controller/AttachmentApiController.php index 9d2eff0..eeb79b4 100644 --- a/lib/Controller/AttachmentApiController.php +++ b/lib/Controller/AttachmentApiController.php @@ -63,7 +63,12 @@ class AttachmentApiController extends ApiController { $file = array_pop($files); + if (!empty($file) && array_key_exists('error', $file) && $file['error'] !== UPLOAD_ERR_OK) { + return new JSONResponse([],Http::STATUS_BAD_REQUEST); + } + $fileId = $this->fileService->upload($file['name'], file_get_contents($file['tmp_name'])); + return new JSONResponse([ 'file_id' => $fileId, 'preview_url' => $this->fileService->getPreviewUrl($fileId, 512),