php-doc-en/reference/mongo/mongogridfsfile/getresource.xml
Derick Rethans 2d79464bc3 Clarified that it is for reading only.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@330745 c90b9560-bf6c-de11-be94-00142212c4b1
2013-07-03 09:25:33 +00:00

82 lines
2.1 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="mongogridfsfile.getresource" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>MongoGridFSFile::getResource</refname>
<refpurpose>Returns a resource that can be used to read the stored file</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>stream</type><methodname>MongoGridFSFile::getResource</methodname>
<void/>
</methodsynopsis>
<para>
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.
</para>
<para>
At most two GridFSFile chunks will be loaded in memory.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a resource that can be used to read the file with
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><methodname>MongoGridFSFile::getResource</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?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($stream, 8192);
}
?>
]]>
</programlisting>
</example>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->