An Upload object is usually created by calling [[Collection::createUpload()]]. Note: instance of this class is 'single use' only. Do not attempt to use same Upload instance for multiple file upload. Usage example: php $document = Yii::$app->mongodb->getFileCollection()->createUpload() ->addContent('Part 1') ->addContent('Part 2') ... ->complete();
Since: 2.1
Author: Paul Klimov (klimov.paul@gmail.com)
Inheritance: extends yii\base\Object
Example #1
0
 /**
  * Prepares [[Upload]] instance for the write operations.
  * @return bool success.
  * @throws InvalidConfigException on invalid context configuration.
  */
 private function prepareUpload()
 {
     $contextOptions = $this->getContextOptions();
     if (isset($contextOptions[$this->protocol]['upload'])) {
         $upload = $contextOptions[$this->protocol]['upload'];
         if (!$upload instanceof Upload) {
             throw new InvalidConfigException('"upload" context option should be an instance of "' . Upload::className() . '"');
         }
         $this->upload = $upload;
         return true;
     }
     $collection = $this->fetchCollection();
     $this->upload = $collection->createUpload(['document' => $this->queryParams]);
     return true;
 }