node.js - How to save the ID of a saved file using GridFS? -


i trying save id of file send via gridfs mongodb (working mongoose). cant seem find out how created id in fs.files code?

var writestream = gfs.createwritestream({     filename: req.file.originalname });  fs.createreadstream(req.file.path).pipe(writestream);  writestream.on('close', function (file) {     // `file`     console.log(file.filename + 'written db'); }); 

i cant seem able save id of file wrote via writestream.

the file created in lists etc. how manage save file can save in 1 of other mongodb documents?

this old , think solved problem. if correctly understood, trying id of saved file. can this:

console.log(writestream.id); 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -