gridform icon indicating copy to clipboard operation
gridform copied to clipboard

File upload problem using gridfs-stream 0.5.0

Open kennyerasmuson opened this issue 10 years ago • 4 comments

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)

kennyerasmuson avatar Oct 08 '15 10:10 kennyerasmuson

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

zevero avatar Mar 07 '16 10:03 zevero

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

zevero avatar Mar 07 '16 11:03 zevero

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.

kennyerasmuson avatar Mar 07 '16 20:03 kennyerasmuson

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!

zevero avatar Feb 27 '17 18:02 zevero