aheckmann / gridfs-stream

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

gfs.remove does not work when passing a string #105

Open mathiash98 opened 7 years ago

mathiash98 commented 7 years ago

If you try to pass a string for example req.params.id the file won't be deleted. You have to convert it to an object first!

var _id = mongoose.Types.ObjectId(req.params.fileid); And then use that converted objectid when deleting files.

Suggestion to fix the bug: Check if the passed id/filename has typeof object, if not run code above.