Open mathiash98 opened 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.
var _id = mongoose.Types.ObjectId(req.params.fileid);
Suggestion to fix the bug: Check if the passed id/filename has typeof object, if not run code above.
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.