attachmentService = $attachmentService; $this->userId = $UserId; } /** * @NoAdminRequired * * @return JSONResponse */ #[TrapError] public function create(): JSONResponse { $file = $this->request->getUploadedFile('attachment'); if (is_null($file)) { throw new ClientException('no file attached'); } $uploadedFile = new UploadedFile($file); $attachment = $this->attachmentService->addFile($this->userId, $uploadedFile); return new JSONResponse($attachment, Http::STATUS_CREATED); } }