Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-610

Saving a file in Mongodb's GridFS with pymongo results in a truncated file - python 2.7 on Windows 7

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.3
    • Component/s: None
    • Environment:
      python 2.7
      Windows 7
      mongodb 2.2.3 (running on Ubuntu)

      Saving a file in Mongodb's GridFS with pymongo results in a truncated file.

      Example:

      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

      On Windows 7, running this program generates this output:

      145047
      864

      On Ubuntu, running this program generates this (correct) output:

      145047
      145047

      so you can reproduce my example more rigorously, 'owl.jpg' was downloaded from: http://getintobirds.audubon.org/sites/default/files/photos/wildlife_barn_owl.jpg

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            dustin Dustin Reagan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: