aheckmann / gridform

Stream formidable uploads into MongoDB GridFS
http://aheckmann.github.com/gridform/
MIT License
59 stars 17 forks source link

File upload problem using gridfs-stream 0.5.0 #14

Open kennyerasmuson opened 8 years ago

kennyerasmuson commented 8 years ago

My code for uploading files was working with gridform until updating Mongoose to v4.x.x. When a file upload is attempted the following error occurs:

/Users/kenny/Dropbox/Dev/vqfolio/node_modules/gridform/node_modules/gridfs-stream/lib/writestream.js:44 this.id = new grid.mongo.BSONPure.ObjectID; ^ TypeError: Cannot read property 'ObjectID' of undefined at Stream.GridWriteStream (/Users/kenny/Dropbox/Dev/vqfolio/node_modules/gridform/node_modules/gridfs-stream/lib/writestream.js:44:38)

It looks like similar issues have been seen for others using gridfs-stream: https://github.com/aheckmann/gridfs-stream/issues/74

Does the version of gridfs-stream and mongodb that gridform currently use need to be updated to fix this issue? (current versions used by gridform 0.1.7 are gridfs-stream 0.5.0 and mongodb 1.4.3)

zevero commented 8 years ago

well its sad ... I get the same error ...

zevero commented 8 years ago

I hope this will can be fixed. For the meantime we can apply the hotfix given in the reference above:

var MongoDB  = require('mongodb');
MongoDB.BSONPure = require('bson').BSONPure; //hotfix for gridform v0.1.7
kennyerasmuson commented 8 years ago

I tried that fix in the past and found it didn't work for me... instead I took a copy of the files, file.js and gridform.js to my project and then included the following in my project.json file:

"events": "*", "formidable": "*", "gridfs-stream": "*"

then "require" the gridform file into your js file.

zevero commented 7 years ago

Today I updated my project and I got the same issue! Bson is now at Version 1.0.4 an there seems to be no BSONPure anymore ... My working new hotfix is

var MongoDB  = require('mongodb');
MongoDB.BSONPure = require('bson').BSON; //hotfix for gridform v0.1.7 with bson v1.0.4

Cheers!