title: Saving a file in Mongodb's GridFS with pymongo results in a truncated file - python 2.7 on Windows 7
body: <p>Saving a file in Mongodb's GridFS with pymongo results in a truncated file.  </p>
  
  <pre><code>from pymongo import MongoClient
  import gridfs
  import os
  
  #just to make sure we aren't crazy, check the filesize on disk:
  print os.path.getsize( r'owl.jpg' )
  
  #add the file to GridFS, per the pymongo documentation: http://api.mongodb.org/python/current/examples/gridfs.html
  db = MongoClient().myDB
  fs = gridfs.GridFS( db )
  fileID = fs.put( open( r'owl.jpg', 'r')  )
  out = fs.get(fileID)
  print out.length
  </code></pre>
  
  <p>On Windows 7, running this program generates this output:</p>
  
  <pre><code>145047
  864
  </code></pre>
  
  <p>On Ubuntu, running this program generates this (correct) output:</p>
  
  <pre><code>145047
  145047
  </code></pre>
  
  <p>Unfortunately, the application I'm working on is targeting the Windows OS...</p>
  
  <p>Any help would be appreciated!</p>
  
  <p>so you can reproduce my example more rigorously, 'owl.jpg' was downloaded from:   <a href="http://getintobirds.audubon.org/sites/default/files/photos/wildlife_barn_owl.jpg" rel="noreferrer">http://getintobirds.audubon.org/sites/default/files/photos/wildlife_barn_owl.jpg</a> </p>