Navigation

MongoDB\GridFS\Bucket::openDownloadStream()

Definition

MongoDB\GridFS\Bucket::openDownloadStream

Selects a GridFS file by its _id and opens it as a readable stream.

function openDownloadStream($id): resource

This method has the following parameters:

Parameter Type Description
$id mixed The _id of the file.

Return Values

A readable stream resource.

Errors/Exceptions

MongoDB\GridFS\Exception\FileNotFoundException if no file was found for the selection criteria.

MongoDB\Driver\Exception\RuntimeException for other errors at the driver level (e.g. connection errors).