yii\mongodb\file\Download::toStream PHP Method

toStream() public method

Saves file into the given stream.
public toStream ( resource $stream ) : integer
$stream resource stream, which file should be saved to.
return integer number of written bytes.
    public function toStream($stream)
    {
        $bytesWritten = 0;
        foreach ($this->getChunkCursor() as $chunk) {
            $bytesWritten += fwrite($stream, $chunk['data']->getData());
        }
        return $bytesWritten;
    }