/**
  * @param Request $request
  * @return Response
  */
 public function prepare(Request $request)
 {
     $this->headers->set('Content-Length', $this->file->getSize());
     if (!$this->headers->has('Content-Type')) {
         $this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream');
     }
     if ('HTTP/1.0' != $request->server->get('SERVER_PROTOCOL')) {
         $this->setProtocolVersion('1.1');
     }
     return $this;
 }
 /**
  * @param $event \trntv\filekit\events\StorageEvent
  */
 public function afterSave($event)
 {
     $file = new File($event->filesystem, $event->path);
     $model = new FileStorageItem();
     $model->component = $this->component;
     $model->path = $file->getPath();
     $model->base_url = $this->getStorage()->baseUrl;
     $model->size = $file->getSize();
     $model->type = $file->getMimeType();
     $model->name = pathinfo($file->getPath(), PATHINFO_FILENAME);
     if (Yii::$app->request->getIsConsoleRequest() === false) {
         $model->upload_ip = Yii::$app->request->getUserIP();
     }
     $model->save(false);
 }