MongoDB\GridFS\Bucket::getFileDocumentForStream()
定义
参数
$stream
: 资源- GridFS流资源。
返回值
与GridFS流关联的元数据文档。返回类型将取决于bucket的typeMap
选项。
错误/异常
MongoDB\Exception\InvalidArgumentException
与参数或选项解析相关的错误。
MongoDB\Driver\Exception\RuntimeException 与扩展级别的其他错误(例如连接错误)相关。
示例
$bucket = (new MongoDB\Client)->test->selectGridFSBucket(); $stream = $bucket->openUploadStream('filename'); $fileDocument = $bucket->getFileDocumentForStream($stream); var_dump($fileDocument); fclose($stream);
输出将类似于
object(MongoDB\Model\BSONDocument)#4956 (1) { ["storage":"ArrayObject":private]=> array(3) { ["_id"]=> object(MongoDB\BSON\ObjectId)#4955 (1) { ["oid"]=> string(24) "5acfb05b7e21e83b5a29037c" } ["chunkSize"]=> int(261120) ["filename"]=> string(8) "filename" } }