GoLang MongoGridFSFile::getResource

request it (261)
GoLang replacement for PHP's MongoGridFSFile::getResource [edit | history]



Do you know a GoLang replacement for PHP's MongoGridFSFile::getResource? Write it!

PHP MongoGridFSFile::getResource

PHP original manual for MongoGridFSFile::getResource [ show | php.net ]

MongoGridFSFile::getResource

(PECL mongo >=1.3.0)

MongoGridFSFile::getResourceReturns a resource that can be used to read the stored file

Description

public resource MongoGridFSFile::getResource ( void )

This method returns a stream resource that can be used with all file functions in PHP that deal with reading files. The contents of the file are pulled out of MongoDB on the fly, so that the whole file does not have to be loaded into memory first.

At most two GridFSFile chunks will be loaded in memory.

Parameters

This function has no parameters.

Return Values

Returns a resource that can be used to read the file with

Examples

Example #1 MongoGridFSFile::getResource() example

<?php
$m 
= new Mongo;
$images $m->my_db->getGridFS('images');

$image $images->findOne('mongo.png');

header('Content-type: image/png;');
$stream $image->getResource();

while (!
feof($stream)) {
    echo 
fread($stream8192);
}
?>