public function uploadAction(Request $request)
 {
     $config = $request->get('config', array());
     if (false === $this->imageValidator->isConfigValid($config)) {
         throw new InvalidImageConfigException('Image config is not valid!');
     }
     $config = ImageConfigHelper::normalize($config);
     if (false === $this->tokenValidator->isValid($request->get('token'), $config)) {
         throw new NotFoundHttpException('Invalid upload token!');
     }
     return new JsonResponse($this->uploadHandler->process($request->files->get('image', null), $config));
 }
Ejemplo n.º 2
0
 public function testIsConfigValidException()
 {
     $this->setExpectedException('Silvestra\\Component\\Media\\Exception\\InvalidImageConfigException');
     $this->validator->addConfigValidator(new MaxFileSizeValidator());
     $this->validator->isConfigValid(array());
 }