使用yii2gridfs下载文件

使用yii2gridfs下载文件,yii2,gridfs,Yii2,Gridfs,我想使用YII2从gridfs下载文件。我是Yii的新手我用过这个代码 class classname extends \path\controller{ $connection = new \yii\mongodb\Connection([ 'dsn' => 'mongodb://localhost:27017/files', ]); $connection->open(); $fileCollection = new Co

我想使用YII2从gridfs下载文件。我是Yii的新手我用过这个代码

   class classname extends \path\controller{   
   $connection = new \yii\mongodb\Connection([
        'dsn' => 'mongodb://localhost:27017/files',
    ]);
    $connection->open();
    $fileCollection = new Collection();
    $collection = $connection->getCollection('fs.files');
    $records = $collection->findOne(["_id"=>'548171105e24cfe00c0000ee'],["filename"]);
但我已经检索了文件的详细信息。任何人都可以告诉我如何进一步下载文件。

您可以使用fileSend()方法


虽然此链接可以回答问题,但最好在此处包含答案的基本部分,并提供链接供参考。如果链接页面发生更改,则仅链接的答案可能无效。