public insertFile ( string $filename, array $metadata = [], array $options = [] ) : mixed | ||
$filename | string | name of the file 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 insertFile($filename, $metadata = [], $options = [])
{
$options['document'] = $metadata;
$document = $this->createUpload($options)->addFile($filename)->complete();
return $document['_id'];
}