aheckmann / gridfs-stream

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

Fix a bug of GridWriteStream constructor #71

Closed pine closed 9 years ago

pine commented 9 years ago

Hello. I use this library in my project, and I found a bug in GridWriteStream constructor.

In README.md, written as following:

var writestream = gfs.createWriteStream([options]);
fs.createReadStream('/some/path').pipe(writestream);

So I wrote this code and ran it.

var writestream = gfs.createWriteStream();

It failed, and it output some error logs.

TypeError: Cannot read property '_id' of undefined
      at new GridWriteStream (C:\Users\pine\Dropbox\Repos\_fork\gridfs-stream\lib\writestream.js:44:12)
      at Grid.createWriteStream (C:\Users\pine\Dropbox\Repos\_fork\gridfs-stream\lib\index.js:42:10)

I fixed this bug, and added some tests. Thank you.

Reggino commented 9 years ago

Good catch! Thanks.