Dont upload rejected files

This commit is contained in:
Matias De lellis
2020-11-18 19:14:40 -03:00
parent b5dfa7c65d
commit 35d548383a

View File

@@ -63,7 +63,12 @@ class AttachmentApiController extends ApiController {
$file = array_pop($files); $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'])); $fileId = $this->fileService->upload($file['name'], file_get_contents($file['tmp_name']));
return new JSONResponse([ return new JSONResponse([
'file_id' => $fileId, 'file_id' => $fileId,
'preview_url' => $this->fileService->getPreviewUrl($fileId, 512), 'preview_url' => $this->fileService->getPreviewUrl($fileId, 512),