/**
  * Creates a new Hwboxfw model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     // preparing for file upload to sae storage
     $s2 = new SaeStorage();
     $model = new Hwboxfw();
     if ($model->load(Yii::$app->request->post())) {
         // get the instance of the uploaded file
         $model->file = UploadedFile::getInstance($model, 'file');
         //$model->file = $s2->inputFile(UploadedFile::getInstance($model,'file'));
         //$model->file = $s2->inputFile($file);
         // 上传一个文件
         //Storage::putObject(Storage::inputFile($file), $bucketName, $uploadName)
         $imageName = $model->file->name;
         //keep original file name in server
         $tempName = $model->file->tempName;
         $fileSize = $model->file->size;
         //$model->file->saveAs('uploads/'.$imageName.'.'.$model->file->extension ); // save file in server with same extension
         // $name = $_FILES['file'][$imageName];
         // $s2->upload('uploads',$name,$_FILES['file']['tmp_name']);
         $bucketName = 'uploads';
         //$model->file to be investigated
         //$bucketName and $imageName is CORRECT;
         //$s2->putObject($model->file, $bucketName, $imageName); //此行语句仅仅将$_FILES的各种属性记录下来保存到文件里,文件实际内容丢失
         //$dumpdata = file_get_contents($_FILES["file"]["tmp_name"]);
         //$dowLoadUrl = $stor->write($domain,$fileDataName,$dumpdata);//用write就行了
         $dumpdata = file_get_contents($tempName);
         $inputFile = $s2->inputFile($tempName);
         $s2->putObject($inputFile, $bucketName, $imageName);
         // 上传一个文件的用法,但在yii/web/UploadedFile中,只有对其属性的操作,可能还是需要用COPY的方法从TEMP_NAME到目的地目录
         //Storage::putObject(Storage::inputFile($file), $bucketName, $uploadName)
         //var_dump($model->file);
         ///        var_dump($_FILES);
         //save the path in the db column
         $model->file_path_name = $s2->getUrl("uploads", $imageName);
         //$model->file = 'uploads/'.$imageName.'.'.$model->file->extension ;
         //$model->file_path_name = 'uploads/'.$imageName;
         //$model->date = date('Y-m-d h:m:s');
         // save the date and time as a record of input moment
         $model->save();
         //这一步会检查RULES,如果强制REQUIRED,这一步不会成功,那么FWID的自增值就取不到,后面redirect出错
         return $this->redirect(['view', 'id' => $model->FWID]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }