To specify source file use the [[file]] attribute. It can be specified in one of the following ways: - string - full name of the file, which content should be stored in GridFS - \yii\web\UploadedFile - uploaded file instance, which content should be stored in GridFS For example: php $record = new ImageFile(); $record->file = '/path/to/some/file.jpg'; $record->save(); You can also specify file content via [[newFileContent]] attribute: php $record = new ImageFile(); $record->newFileContent = 'New file content'; $record->save(); Note: [[newFileContent]] always takes precedence over [[file]].
Since: 2.0
Author: Paul Klimov (klimov.paul@gmail.com)
Inheritance: extends yii\mongodb\ActiveRecord
Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function beforeSave($insert)
 {
     if (!parent::beforeSave($insert)) {
         return false;
     }
     $this->refreshFromEmbedded();
     return true;
 }
Exemplo n.º 2
0
 public function rules()
 {
     return array_merge(parent::rules(), [[['ownerId', 'contentType'], 'required'], ['ownerId', 'exist', 'targetClass' => Number::className(), 'targetAttribute' => '_id'], [['file'], 'file']]);
 }
Exemplo n.º 3
0
 public function attributes()
 {
     return array_merge(parent::attributes(), ['mimeType']);
 }
Exemplo n.º 4
0
 public function attributes()
 {
     return array_merge(parent::attributes(), ['userId', 'contentType', 'description']);
 }
Exemplo n.º 5
0
 public function attributes()
 {
     return array_merge(parent::attributes(), ['filename', 'metadata', 'metadatanew', 'uploadDate', 'groups', 'onlineStatus', 'updated_by', 'updated_at']);
 }
Exemplo n.º 6
0
 public function attributes()
 {
     return array_merge(parent::attributes(), ['filesize', 'filetype']);
 }