aheckmann / gridfs-stream

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

Can't work out how to remove a file #143

Open MotorCityCobra opened 5 years ago

MotorCityCobra commented 5 years ago
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.

kurdi89 commented 5 years ago

try using methodoverride npm package

dietergeerts commented 5 years ago

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+

Chinmaygoyal commented 5 years ago

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

shivamraina commented 2 years ago

If it will help someone, I deleted using this

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