gridfs-stream icon indicating copy to clipboard operation
gridfs-stream copied to clipboard

Can't work out how to remove a file

Open MotorCityCobra opened this issue 7 years ago • 4 comments

app.delete('/files/:id', (req, res) => {
gfs.remove({_id: req.params.id, root: 'uploads'}, (err, gridStore) => {

'uploads' is the name of my bucket. This command is not getting it done.

MotorCityCobra avatar Apr 12 '19 21:04 MotorCityCobra

try using methodoverride npm package

kurdi89 avatar Jun 06 '19 02:06 kurdi89

try using methodoverride npm package

That's not very descriptive. I have the same problem, I got errors:

MongoError: read preference must be a ReadPreference instance

Using mongoose 5+

dietergeerts avatar Jul 04 '19 16:07 dietergeerts

I worked with gfs.remove and it worked fine for me. @manjia does it show an error or it doesn't change anything?

Chinmaygoyal avatar Jul 12 '19 00:07 Chinmaygoyal

If it will help someone, I deleted using this

const bucket = new mongodb.GridFSBucket(conn.db, { bucketName: 'uploads' });
bucket.delete(ObjectId("60edece5e06275bf0463aaf3"));

shivamraina avatar Mar 27 '22 18:03 shivamraina