/usr/share/doc/python-pymongo-doc/html/api/gridfs/grid_file.html is in python-pymongo-doc 2.6.3-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>grid_file – Tools for representing files stored in GridFS — PyMongo 2.6.3 documentation</title>
<link rel="stylesheet" href="../../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../',
VERSION: '2.6.3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="../../_static/sidebar.js"></script>
<link rel="top" title="PyMongo 2.6.3 documentation" href="../../index.html" />
<link rel="up" title="gridfs – Tools for working with GridFS" href="index.html" />
<link rel="next" title="Tools" href="../../tools.html" />
<link rel="prev" title="errors – Exceptions raised by the gridfs package" href="errors.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="../../tools.html" title="Tools"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="errors.html" title="errors – Exceptions raised by the gridfs package"
accesskey="P">previous</a> |</li>
<li><a href="../../index.html">PyMongo 2.6.3 documentation</a> »</li>
<li><a href="../index.html" >API Documentation</a> »</li>
<li><a href="index.html" accesskey="U"><tt class="docutils literal"><span class="pre">gridfs</span></tt> – Tools for working with GridFS</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-gridfs.grid_file">
<span id="grid-file-tools-for-representing-files-stored-in-gridfs"></span><h1><tt class="xref py py-mod docutils literal"><span class="pre">grid_file</span></tt> – Tools for representing files stored in GridFS<a class="headerlink" href="#module-gridfs.grid_file" title="Permalink to this headline">¶</a></h1>
<p>Tools for representing files stored in GridFS.</p>
<dl class="class">
<dt id="gridfs.grid_file.GridIn">
<em class="property">class </em><tt class="descclassname">gridfs.grid_file.</tt><tt class="descname">GridIn</tt><big>(</big><em>root_collection</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#gridfs.grid_file.GridIn" title="Permalink to this definition">¶</a></dt>
<dd><p>Write a file to GridFS</p>
<p>Application developers should generally not need to
instantiate this class directly - instead see the methods
provided by <a class="reference internal" href="index.html#gridfs.GridFS" title="gridfs.GridFS"><tt class="xref py py-class docutils literal"><span class="pre">GridFS</span></tt></a>.</p>
<p>Raises <tt class="xref py py-class docutils literal"><span class="pre">TypeError</span></tt> if <cite>root_collection</cite> is not an
instance of <a class="reference internal" href="../pymongo/collection.html#pymongo.collection.Collection" title="pymongo.collection.Collection"><tt class="xref py py-class docutils literal"><span class="pre">Collection</span></tt></a>.</p>
<p>Any of the file level options specified in the <a class="reference external" href="http://dochub.mongodb.org/core/gridfsspec">GridFS Spec</a> may be passed as
keyword arguments. Any additional keyword arguments will be
set as additional fields on the file document. Valid keyword
arguments include:</p>
<blockquote>
<div><ul class="simple">
<li><tt class="docutils literal"><span class="pre">"_id"</span></tt>: unique ID for this file (default:
<a class="reference internal" href="../bson/objectid.html#bson.objectid.ObjectId" title="bson.objectid.ObjectId"><tt class="xref py py-class docutils literal"><span class="pre">ObjectId</span></tt></a>) - this <tt class="docutils literal"><span class="pre">"_id"</span></tt> must
not have already been used for another file</li>
<li><tt class="docutils literal"><span class="pre">"filename"</span></tt>: human name for the file</li>
<li><tt class="docutils literal"><span class="pre">"contentType"</span></tt> or <tt class="docutils literal"><span class="pre">"content_type"</span></tt>: valid mime-type
for the file</li>
<li><tt class="docutils literal"><span class="pre">"chunkSize"</span></tt> or <tt class="docutils literal"><span class="pre">"chunk_size"</span></tt>: size of each of the
chunks, in bytes (default: 256 kb)</li>
<li><tt class="docutils literal"><span class="pre">"encoding"</span></tt>: encoding used for this file. In Python 2,
any <tt class="xref py py-class docutils literal"><span class="pre">unicode</span></tt> that is written to the file will be
converted to a <tt class="xref py py-class docutils literal"><span class="pre">str</span></tt>. In Python 3, any <tt class="xref py py-class docutils literal"><span class="pre">str</span></tt>
that is written to the file will be converted to
<tt class="xref py py-class docutils literal"><span class="pre">bytes</span></tt>.</li>
</ul>
</div></blockquote>
<p>If you turn off write-acknowledgment for performance reasons, it is
critical to wrap calls to <a class="reference internal" href="#gridfs.grid_file.GridIn.write" title="gridfs.grid_file.GridIn.write"><tt class="xref py py-meth docutils literal"><span class="pre">write()</span></tt></a> and <a class="reference internal" href="#gridfs.grid_file.GridIn.close" title="gridfs.grid_file.GridIn.close"><tt class="xref py py-meth docutils literal"><span class="pre">close()</span></tt></a> within a
single request:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pymongo</span> <span class="kn">import</span> <span class="n">MongoClient</span>
<span class="gp">>>> </span><span class="kn">from</span> <span class="nn">gridfs</span> <span class="kn">import</span> <span class="n">GridFS</span>
<span class="gp">>>> </span><span class="n">client</span> <span class="o">=</span> <span class="n">MongoClient</span><span class="p">(</span><span class="n">w</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> <span class="c"># turn off write acknowledgment</span>
<span class="gp">>>> </span><span class="n">fs</span> <span class="o">=</span> <span class="n">GridFS</span><span class="p">(</span><span class="n">client</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">gridin</span> <span class="o">=</span> <span class="n">fs</span><span class="o">.</span><span class="n">new_file</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">request</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">start_request</span><span class="p">()</span>
<span class="gp">>>> </span><span class="k">try</span><span class="p">:</span>
<span class="gp">... </span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">):</span>
<span class="gp">... </span> <span class="n">gridin</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">'foo'</span><span class="p">)</span>
<span class="gp">... </span> <span class="n">gridin</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="gp">... </span><span class="k">finally</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">request</span><span class="o">.</span><span class="n">end</span><span class="p">()</span>
</pre></div>
</div>
<p>In Python 2.5 and later this code can be simplified with a
with-statement, see <a class="reference internal" href="../../examples/requests.html"><em>Requests</em></a> for more information.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><cite>root_collection</cite>: root collection to write to</li>
<li><cite>**kwargs</cite> (optional): file level options (see above)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="gridfs.grid_file.GridIn._id">
<tt class="descname">_id</tt><a class="headerlink" href="#gridfs.grid_file.GridIn._id" title="Permalink to this definition">¶</a></dt>
<dd><p>The <tt class="docutils literal"><span class="pre">'_id'</span></tt> value for this file.</p>
<p>This attribute is read-only.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridIn.chunk_size">
<tt class="descname">chunk_size</tt><a class="headerlink" href="#gridfs.grid_file.GridIn.chunk_size" title="Permalink to this definition">¶</a></dt>
<dd><p>Chunk size for this file.</p>
<p>This attribute is read-only.</p>
</dd></dl>
<dl class="method">
<dt id="gridfs.grid_file.GridIn.close">
<tt class="descname">close</tt><big>(</big><big>)</big><a class="headerlink" href="#gridfs.grid_file.GridIn.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Flush the file and close it.</p>
<p>A closed file cannot be written any more. Calling
<a class="reference internal" href="#gridfs.grid_file.GridIn.close" title="gridfs.grid_file.GridIn.close"><tt class="xref py py-meth docutils literal"><span class="pre">close()</span></tt></a> more than once is allowed.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridIn.closed">
<tt class="descname">closed</tt><a class="headerlink" href="#gridfs.grid_file.GridIn.closed" title="Permalink to this definition">¶</a></dt>
<dd><p>Is this file closed?</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridIn.content_type">
<tt class="descname">content_type</tt><a class="headerlink" href="#gridfs.grid_file.GridIn.content_type" title="Permalink to this definition">¶</a></dt>
<dd><p>Mime-type for this file.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridIn.filename">
<tt class="descname">filename</tt><a class="headerlink" href="#gridfs.grid_file.GridIn.filename" title="Permalink to this definition">¶</a></dt>
<dd><p>Name of this file.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridIn.length">
<tt class="descname">length</tt><a class="headerlink" href="#gridfs.grid_file.GridIn.length" title="Permalink to this definition">¶</a></dt>
<dd><p>Length (in bytes) of this file.</p>
<p>This attribute is read-only and can only be read after <a class="reference internal" href="#gridfs.grid_file.GridIn.close" title="gridfs.grid_file.GridIn.close"><tt class="xref py py-meth docutils literal"><span class="pre">close()</span></tt></a> has been called.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridIn.md5">
<tt class="descname">md5</tt><a class="headerlink" href="#gridfs.grid_file.GridIn.md5" title="Permalink to this definition">¶</a></dt>
<dd><p>MD5 of the contents of this file (generated on the server).</p>
<p>This attribute is read-only and can only be read after <a class="reference internal" href="#gridfs.grid_file.GridIn.close" title="gridfs.grid_file.GridIn.close"><tt class="xref py py-meth docutils literal"><span class="pre">close()</span></tt></a> has been called.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridIn.name">
<tt class="descname">name</tt><a class="headerlink" href="#gridfs.grid_file.GridIn.name" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for <cite>filename</cite>.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridIn.upload_date">
<tt class="descname">upload_date</tt><a class="headerlink" href="#gridfs.grid_file.GridIn.upload_date" title="Permalink to this definition">¶</a></dt>
<dd><p>Date that this file was uploaded.</p>
<p>This attribute is read-only and can only be read after <a class="reference internal" href="#gridfs.grid_file.GridIn.close" title="gridfs.grid_file.GridIn.close"><tt class="xref py py-meth docutils literal"><span class="pre">close()</span></tt></a> has been called.</p>
</dd></dl>
<dl class="method">
<dt id="gridfs.grid_file.GridIn.write">
<tt class="descname">write</tt><big>(</big><em>data</em><big>)</big><a class="headerlink" href="#gridfs.grid_file.GridIn.write" title="Permalink to this definition">¶</a></dt>
<dd><p>Write data to the file. There is no return value.</p>
<p><cite>data</cite> can be either a string of bytes or a file-like object
(implementing <tt class="xref py py-meth docutils literal"><span class="pre">read()</span></tt>). If the file has an
<tt class="xref py py-attr docutils literal"><span class="pre">encoding</span></tt> attribute, <cite>data</cite> can also be a
<tt class="xref py py-class docutils literal"><span class="pre">unicode</span></tt> (<tt class="xref py py-class docutils literal"><span class="pre">str</span></tt> in python 3) instance, which
will be encoded as <tt class="xref py py-attr docutils literal"><span class="pre">encoding</span></tt> before being written.</p>
<p>Due to buffering, the data may not actually be written to the
database until the <a class="reference internal" href="#gridfs.grid_file.GridIn.close" title="gridfs.grid_file.GridIn.close"><tt class="xref py py-meth docutils literal"><span class="pre">close()</span></tt></a> method is called. Raises
<tt class="xref py py-class docutils literal"><span class="pre">ValueError</span></tt> if this file is already closed. Raises
<tt class="xref py py-class docutils literal"><span class="pre">TypeError</span></tt> if <cite>data</cite> is not an instance of
<tt class="xref py py-class docutils literal"><span class="pre">str</span></tt> (<tt class="xref py py-class docutils literal"><span class="pre">bytes</span></tt> in python 3), a file-like object,
or an instance of <tt class="xref py py-class docutils literal"><span class="pre">unicode</span></tt> (<tt class="xref py py-class docutils literal"><span class="pre">str</span></tt> in python 3).
Unicode data is only allowed if the file has an <tt class="xref py py-attr docutils literal"><span class="pre">encoding</span></tt>
attribute.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><cite>data</cite>: string of bytes or file-like object to be written
to the file</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.9: </span>The ability to write <tt class="xref py py-class docutils literal"><span class="pre">unicode</span></tt>, if the file has an
<tt class="xref py py-attr docutils literal"><span class="pre">encoding</span></tt> attribute.</p>
</div>
</dd></dl>
<dl class="method">
<dt id="gridfs.grid_file.GridIn.writelines">
<tt class="descname">writelines</tt><big>(</big><em>sequence</em><big>)</big><a class="headerlink" href="#gridfs.grid_file.GridIn.writelines" title="Permalink to this definition">¶</a></dt>
<dd><p>Write a sequence of strings to the file.</p>
<p>Does not add seperators.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="gridfs.grid_file.GridOut">
<em class="property">class </em><tt class="descclassname">gridfs.grid_file.</tt><tt class="descname">GridOut</tt><big>(</big><em>root_collection</em>, <em>file_id=None</em>, <em>file_document=None</em><big>)</big><a class="headerlink" href="#gridfs.grid_file.GridOut" title="Permalink to this definition">¶</a></dt>
<dd><p>Read a file from GridFS</p>
<p>Application developers should generally not need to
instantiate this class directly - instead see the methods
provided by <a class="reference internal" href="index.html#gridfs.GridFS" title="gridfs.GridFS"><tt class="xref py py-class docutils literal"><span class="pre">GridFS</span></tt></a>.</p>
<p>Either <cite>file_id</cite> or <cite>file_document</cite> must be specified,
<cite>file_document</cite> will be given priority if present. Raises
<tt class="xref py py-class docutils literal"><span class="pre">TypeError</span></tt> if <cite>root_collection</cite> is not an instance of
<a class="reference internal" href="../pymongo/collection.html#pymongo.collection.Collection" title="pymongo.collection.Collection"><tt class="xref py py-class docutils literal"><span class="pre">Collection</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><cite>root_collection</cite>: root collection to read from</li>
<li><cite>file_id</cite>: value of <tt class="docutils literal"><span class="pre">"_id"</span></tt> for the file to read</li>
<li><cite>file_document</cite>: file document from <cite>root_collection.files</cite></li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.9: </span>The <cite>file_document</cite> parameter.</p>
</div>
<dl class="attribute">
<dt id="gridfs.grid_file.GridOut._id">
<tt class="descname">_id</tt><a class="headerlink" href="#gridfs.grid_file.GridOut._id" title="Permalink to this definition">¶</a></dt>
<dd><p>The <tt class="docutils literal"><span class="pre">'_id'</span></tt> value for this file.</p>
<p>This attribute is read-only.</p>
</dd></dl>
<dl class="method">
<dt id="gridfs.grid_file.GridOut.__iter__">
<tt class="descname">__iter__</tt><big>(</big><big>)</big><a class="headerlink" href="#gridfs.grid_file.GridOut.__iter__" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an iterator over all of this file’s data.</p>
<p>The iterator will return chunk-sized instances of
<tt class="xref py py-class docutils literal"><span class="pre">str</span></tt> (<tt class="xref py py-class docutils literal"><span class="pre">bytes</span></tt> in python 3). This can be
useful when serving files using a webserver that handles
such an iterator efficiently.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridOut.aliases">
<tt class="descname">aliases</tt><a class="headerlink" href="#gridfs.grid_file.GridOut.aliases" title="Permalink to this definition">¶</a></dt>
<dd><p>List of aliases for this file.</p>
<p>This attribute is read-only.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridOut.chunk_size">
<tt class="descname">chunk_size</tt><a class="headerlink" href="#gridfs.grid_file.GridOut.chunk_size" title="Permalink to this definition">¶</a></dt>
<dd><p>Chunk size for this file.</p>
<p>This attribute is read-only.</p>
</dd></dl>
<dl class="method">
<dt id="gridfs.grid_file.GridOut.close">
<tt class="descname">close</tt><big>(</big><big>)</big><a class="headerlink" href="#gridfs.grid_file.GridOut.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Make GridOut more generically file-like.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridOut.content_type">
<tt class="descname">content_type</tt><a class="headerlink" href="#gridfs.grid_file.GridOut.content_type" title="Permalink to this definition">¶</a></dt>
<dd><p>Mime-type for this file.</p>
<p>This attribute is read-only.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridOut.filename">
<tt class="descname">filename</tt><a class="headerlink" href="#gridfs.grid_file.GridOut.filename" title="Permalink to this definition">¶</a></dt>
<dd><p>Name of this file.</p>
<p>This attribute is read-only.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridOut.length">
<tt class="descname">length</tt><a class="headerlink" href="#gridfs.grid_file.GridOut.length" title="Permalink to this definition">¶</a></dt>
<dd><p>Length (in bytes) of this file.</p>
<p>This attribute is read-only.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridOut.md5">
<tt class="descname">md5</tt><a class="headerlink" href="#gridfs.grid_file.GridOut.md5" title="Permalink to this definition">¶</a></dt>
<dd><p>MD5 of the contents of this file (generated on the server).</p>
<p>This attribute is read-only.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridOut.metadata">
<tt class="descname">metadata</tt><a class="headerlink" href="#gridfs.grid_file.GridOut.metadata" title="Permalink to this definition">¶</a></dt>
<dd><p>Metadata attached to this file.</p>
<p>This attribute is read-only.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridOut.name">
<tt class="descname">name</tt><a class="headerlink" href="#gridfs.grid_file.GridOut.name" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for <cite>filename</cite>.</p>
<p>This attribute is read-only.</p>
</dd></dl>
<dl class="method">
<dt id="gridfs.grid_file.GridOut.read">
<tt class="descname">read</tt><big>(</big><em>size=-1</em><big>)</big><a class="headerlink" href="#gridfs.grid_file.GridOut.read" title="Permalink to this definition">¶</a></dt>
<dd><p>Read at most <cite>size</cite> bytes from the file (less if there
isn’t enough data).</p>
<p>The bytes are returned as an instance of <tt class="xref py py-class docutils literal"><span class="pre">str</span></tt> (<tt class="xref py py-class docutils literal"><span class="pre">bytes</span></tt>
in python 3). If <cite>size</cite> is negative or omitted all data is read.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><cite>size</cite> (optional): the number of bytes to read</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="gridfs.grid_file.GridOut.readline">
<tt class="descname">readline</tt><big>(</big><em>size=-1</em><big>)</big><a class="headerlink" href="#gridfs.grid_file.GridOut.readline" title="Permalink to this definition">¶</a></dt>
<dd><p>Read one line or up to <cite>size</cite> bytes from the file.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><cite>size</cite> (optional): the maximum number of bytes to read</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.9.</span></p>
</div>
</dd></dl>
<dl class="method">
<dt id="gridfs.grid_file.GridOut.seek">
<tt class="descname">seek</tt><big>(</big><em>pos</em>, <em>whence=0</em><big>)</big><a class="headerlink" href="#gridfs.grid_file.GridOut.seek" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the current position of this file.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><cite>pos</cite>: the position (or offset if using relative
positioning) to seek to</li>
<li><cite>whence</cite> (optional): where to seek
from. <tt class="xref py py-attr docutils literal"><span class="pre">os.SEEK_SET</span></tt> (<tt class="docutils literal"><span class="pre">0</span></tt>) for absolute file
positioning, <tt class="xref py py-attr docutils literal"><span class="pre">os.SEEK_CUR</span></tt> (<tt class="docutils literal"><span class="pre">1</span></tt>) to seek relative
to the current position, <tt class="xref py py-attr docutils literal"><span class="pre">os.SEEK_END</span></tt> (<tt class="docutils literal"><span class="pre">2</span></tt>) to
seek relative to the file’s end.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="gridfs.grid_file.GridOut.tell">
<tt class="descname">tell</tt><big>(</big><big>)</big><a class="headerlink" href="#gridfs.grid_file.GridOut.tell" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the current position of this file.</p>
</dd></dl>
<dl class="attribute">
<dt id="gridfs.grid_file.GridOut.upload_date">
<tt class="descname">upload_date</tt><a class="headerlink" href="#gridfs.grid_file.GridOut.upload_date" title="Permalink to this definition">¶</a></dt>
<dd><p>Date that this file was first uploaded.</p>
<p>This attribute is read-only.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="gridfs.grid_file.GridFile">
<em class="property">class </em><tt class="descclassname">gridfs.grid_file.</tt><tt class="descname">GridFile</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#gridfs.grid_file.GridFile" title="Permalink to this definition">¶</a></dt>
<dd><p>No longer supported.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 1.6: </span>The GridFile class is no longer supported.</p>
</div>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="errors.html"
title="previous chapter"><tt class="docutils literal"><span class="pre">errors</span></tt> – Exceptions raised by the <tt class="docutils literal"><span class="pre">gridfs</span></tt> package</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="../../tools.html"
title="next chapter">Tools</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../_sources/api/gridfs/grid_file.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="../../tools.html" title="Tools"
>next</a> |</li>
<li class="right" >
<a href="errors.html" title="errors – Exceptions raised by the gridfs package"
>previous</a> |</li>
<li><a href="../../index.html">PyMongo 2.6.3 documentation</a> »</li>
<li><a href="../index.html" >API Documentation</a> »</li>
<li><a href="index.html" ><tt class="docutils literal"><span class="pre">gridfs</span></tt> – Tools for working with GridFS</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2008 - 2012, 10gen, Inc..
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.
</div>
</body>
</html>
|