src/ngrest/base/Controller.php
public function actionExportDownload($key)
    {
        $sessionkey = Yii::$app->session->get('tempNgRestFileKey');
        $fileName = Yii::$app->session->get('tempNgRestFileName');
        $mimeType = Yii::$app->session->get('tempNgRestFileMime');
        
        if ($sessionkey !== base64_decode($key)) {
            throw new ForbiddenHttpException('Invalid download key.');
        }
    
        $content = FileHelper::getFileContent('@runtime/'.$sessionkey.'.tmp');
    
        Yii::$app->session->remove('tempNgRestFileKey');
        Yii::$app->session->remove('tempNgRestFileName');
        Yii::$app->session->remove('tempNgRestFileMime');
        @unlink(Yii::getAlias('@runtime/'.$sessionkey.'.tmp'));
    
        return Yii::$app->response->sendContentAsFile($content, $fileName, ['mimeType' => $mimeType]);
    }
public function actionExportDownload($key)
    {
        $sessionkey = Yii::$app->session->get('tempNgRestFileKey');
        $fileName = Yii::$app->session->get('tempNgRestFileName');
        $mimeType = Yii::$app->session->get('tempNgRestFileMime');
        
        if ($sessionkey !== base64_decode($key)) {
            throw new ForbiddenHttpException('Invalid download key.');
        }
    
        $content = FileHelper::getFileContent('@runtime/'.$sessionkey.'.tmp');
    
        Yii::$app->session->remove('tempNgRestFileKey');
        Yii::$app->session->remove('tempNgRestFileName');
        Yii::$app->session->remove('tempNgRestFileMime');
        @unlink(Yii::getAlias('@runtime/'.$sessionkey.'.tmp'));
    
        return Yii::$app->response->sendContentAsFile($content, $fileName, ['mimeType' => $mimeType]);
    }
public function actionExportDownload ( $ key ) { $ sessionkey = Yii :: $ app -> session -> get ( 'tempNgRestFileKey' ) ; $ fileName = Yii :: $ app -> session -> get ( 'tempNgRestFileName' ) ; $ mimeType = Yii :: $ app -> session -> get ( 'tempNgRestFileMime' ) ; if ( $ sessionkey !== base64_decode ( $ key ) ) { throw new ForbiddenHttpException ( 'Invalid download key.' ) ; } $ content = FileHelper :: getFileContent ( '@runtime/' . $ sessionkey . '.tmp' ) ; Yii :: $ app -> session -> remove ( 'tempNgRestFileKey' ) ; Yii :: $ app -> session -> remove ( 'tempNgRestFileName' ) ; Yii :: $ app -> session -> remove ( 'tempNgRestFileMime' ) ; @ unlink ( Yii :: getAlias ( '@runtime/' . $ sessionkey . '.tmp' ) ) ; return Yii :: $ app -> response -> sendContentAsFile ( $ content , $ fileName , [ 'mimeType' => $ mimeType ] ) ; }
Get the file content response for a given key.

@param string $key
@throws ForbiddenHttpException
@return \yii\web\Response
Get the file content response for a given key .