public function create(Request $request, Application $app)
 {
     $file = $request->files->get('picture');
     if ($file === null) {
         return $this->json(['status' => 'picture missing']);
     }
     $path = __DIR__ . '/../../../www/upload/';
     $originalFilename = $file->getClientOriginalName();
     $ext = strtolower(substr($originalFilename, strrpos($originalFilename, '.')));
     $filename = uniqid() . $ext;
     $file->move($path, $filename);
     // resizing
     self::resize($path . $filename, 680, 800);
     $username = $request->get('username');
     $user = UserQuery::create()->findOneByName($username);
     if ($user == null) {
         $user = new User();
         $user->setName($username);
         $user->save();
     }
     $wine = new Wine();
     $wine->setName($request->get('name'));
     $wine->setSubmitter($user->getIdUser());
     $wine->setYear($request->get('year'));
     $wine->setPicture($filename);
     $wine->save();
     return $this->json(['id' => $wine->getIdWine()]);
 }