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
コード例 #1
0
ファイル: ActiveRecordFile.php プロジェクト: sammaye/embedded
 /**
  * @inheritdoc
  */
 public function beforeSave($insert)
 {
     if (!parent::beforeSave($insert)) {
         return false;
     }
     $this->refreshFromEmbedded();
     return true;
 }
コード例 #2
0
ファイル: Document.php プロジェクト: shubnikofff/mobiles
 public function rules()
 {
     return array_merge(parent::rules(), [[['ownerId', 'contentType'], 'required'], ['ownerId', 'exist', 'targetClass' => Number::className(), 'targetAttribute' => '_id'], [['file'], 'file']]);
 }
コード例 #3
0
ファイル: File.php プロジェクト: shubnikofff/teleport
 public function attributes()
 {
     return array_merge(parent::attributes(), ['mimeType']);
 }
コード例 #4
0
 public function attributes()
 {
     return array_merge(parent::attributes(), ['userId', 'contentType', 'description']);
 }
コード例 #5
0
ファイル: Documents.php プロジェクト: KasselR/yii2-kr
 public function attributes()
 {
     return array_merge(parent::attributes(), ['filename', 'metadata', 'metadatanew', 'uploadDate', 'groups', 'onlineStatus', 'updated_by', 'updated_at']);
 }
コード例 #6
0
ファイル: UserFile.php プロジェクト: lawguangwei/webDB
 public function attributes()
 {
     return array_merge(parent::attributes(), ['filesize', 'filetype']);
 }