public function actionUpload()
 {
     if (Yii::$app->user->can('createResource')) {
         $form = new UploadForm();
         if (Yii::$app->request->isPost) {
             $file = UploadedFile::getInstance($form, 'file');
             if ($file->getHasError()) {
                 Yii::$app->getSession()->setFlash('error', $file->error);
                 return $this->render('index');
             }
             $upload = Upload::findByUploadedFile($file);
             // TODO: if upload resource already exists for this file, edit existing firmware or create new, take ownership into account
             if (!$upload) {
                 $upload = Upload::createFromUploadedFile($file);
                 if ($upload->hasErrors()) {
                     Yii::$app->getSession()->setFlash('error', $upload->getErrors());
                     return $this->render('index');
                 }
             }
             $firmware = Firmware::createFromUpload($upload);
             if ($firmware->hasErrors()) {
                 Yii::$app->getSession()->setFlash('error', $firmware->getErrors());
                 return $this->render('index');
             }
             return $this->render('edit', ['model' => FirmwareForm::createFromFirmware($firmware)]);
         }
     } else {
         Yii::$app->getSession()->setFlash('error', 'Not allowed.');
         return $this->render('index');
     }
 }