aheckmann / gridfs-stream

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

Gridfs-stream using Mongoclient #138

Open sgokulnath opened 6 years ago

sgokulnath commented 6 years ago

I am trying to use gridfs-stream with mongoclient and read the list of files stored in mongodb

let gfs;
MongoClient.connect("mongodb://localhost:27017/file_upload", function   (err, db) {
    gfs = GridFsStream(db, mongo);
});

router.get('/', function(req, res){
   gfs.collection('uploads').find({}).toArray(function (err, files) {
           if(err) throw err;
           console.log("Function Called");
           console.log(files);
   });
});

When I call the '/' request, it does not show anything. Even the "Function Called" is not printed. Would be helpful if any possible solution is recommended.

Thanks in advance.