aheckmann / gridfs-stream

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

How can I do a replace? #25

Closed pateras closed 11 years ago

pateras commented 11 years ago

I'm using this code to do a file update:

http://pastebin.com/wPibsNus

Basically I'm checking for a file that has an ID stored in metadata. If it exists, I delete it before my save, and if not I just do the save. It seems to work only sporadically. I sometimes see two eroneous behaviors:

  1. The file will be deleted, but not recreated.
  2. The file will appear to be updated, but it won't actually be replaced until I call my code again. So basically I need to do two file uploads for it to register the replace.

It's very sketchy, and I can't really determine a pattern for if it's going to work or not.

So I'm assuming I'm doing something wrong. What's the right way to replace a file using gridfs-stream?

Thank you.

Reggino commented 11 years ago

It has been a while, but the code referred to has been removed...

Closing this issue.