diff --git a/reference/mongo/mongogridfsfile/getresource.xml b/reference/mongo/mongogridfsfile/getresource.xml new file mode 100644 index 0000000000..ea1f0bad92 --- /dev/null +++ b/reference/mongo/mongogridfsfile/getresource.xml @@ -0,0 +1,81 @@ + + + + + + MongoGridFSFile::getResource + Returns a resource that can be used to read the stored file + + + + &reftitle.description; + + public streamMongoGridFSFile::getResource + + + + This method returns a stream resource that can be used with all file + functions in PHP. 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. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + Returns a resource that can be used to read the file with + + + + + &reftitle.examples; + + <methodname>MongoGridFSFile::getResource</methodname> example + +my_db->getGridFS('images'); + +$image = $images->findOne('mongo.png'); + +header('Content-type: image/png;'); +$stream = $image->getResource(); + +while (!feof($stream)) { + echo fread($stream, 8192); +} +?> +]]> + + + + + +