yii\mongodb\file\Collection::insertFileContent PHP Method

insertFileContent() public method

Additional attributes can be added file document using $metadata.
public insertFileContent ( string $bytes, array $metadata = [], array $options = [] ) : mixed
$bytes string string of bytes to store.
$metadata array other metadata fields to include in the file document.
$options array list of options in format: optionName => optionValue
return mixed the "_id" of the saved file document. This will be a generated [[\MongoId]] unless an "_id" was explicitly specified in the metadata.
    public function insertFileContent($bytes, $metadata = [], $options = [])
    {
        $options['document'] = $metadata;
        $document = $this->createUpload($options)->addContent($bytes)->complete();
        return $document['_id'];
    }