aheckmann / gridfs-stream

Easily stream files to and from MongoDB
MIT License
615 stars 120 forks source link

Gridfs-stream createReadStream #140

Open crossSulation opened 5 years ago

crossSulation commented 5 years ago

const readStream =this._gridfs.createReadStream(file.filename); readStream.on('error',(error)=>{ resp.send('No Image from that title!'); resp.end(); }) readStream.pipe(resp);

code like these, when only set up the readStream with filename, it will throw error , this._store = new grid.mongo.GridStore(grid.db, this.id || new grid.mongo.ObjectID(), this.name, this.mode, options);

when I debug, I found grid.mongo.ObjectID is undefined

crossSulation commented 5 years ago

By the way, i am using mongoose

crossSulation commented 5 years ago

sorry, my fault, actually, when construct the GridFSStream, the second argument should the the instance of mongodb

this._gridfs = GridFSStream(this._conn.connection.db,conn.mongo)

crossSulation commented 5 years ago

Made a mistake, actually ,it works, when construct the GRIDFSStream, the second argument should be the instance of moogodb

this._gridfs = GridFSStream(this._conn.connection.db,conn.mongo)