Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
2.6.3
-
None
-
python 2.7
Windows 7
mongodb 2.2.3 (running on Ubuntu)
Description
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