Navigation

MongoDB\GridFS\Bucket::getFileIdForStream()

Definition

MongoDB\GridFS\Bucket::getFileIdForStream

Gets the file document’s ID of the GridFS file associated with a stream.

function getFileIdForStream($stream): mixed

This method has the following parameters:

Parameter Type Description
$stream resource The GridFS stream resource.

Return Values

The _id field of the metadata document associated with the GridFS stream. The return type will depend on the bucket’s typeMap option.

Errors/Exceptions

MongoDB\GridFS\Exception\CorruptFileException if the file’s metadata or chunk documents contain unexpected or invalid data.

MongoDB\Exception\InvalidArgumentException for errors related to the parsing of parameters or options.

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