Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MotorCityCobra opened this issue Apr 12, 2019 · 4 comments
Open

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

MotorCityCobra opened this issue Apr 12, 2019 · 4 comments

Comments

@MotorCityCobra
Copy link

MotorCityCobra commented Apr 12, 2019

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 MotorCityCobra changed the title Added files to the db okay but can't read them Can't work out how to remove a file Apr 15, 2019
@kurdi89
Copy link

kurdi89 commented Jun 6, 2019

try using methodoverride npm package

@dietergeerts
Copy link

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
Copy link

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

@shivamraina
Copy link

If it will help someone, I deleted using this

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@dietergeerts @MotorCityCobra @kurdi89 @Chinmaygoyal @shivamraina and others