-
-
Notifications
You must be signed in to change notification settings - Fork 169
Update GridFS exmaple code #900
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
Update GridFS exmaple code #900
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@harryadel thank you for spotting this issue! Please see my questions regarding implementation
docs/gridfs-bucket-integration.md
Outdated
const uploadStream = bucket | ||
.openUploadStream(file.name, { | ||
contentType: file.type || 'binary/octet-stream', | ||
metadata, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we create uploadStream
above readStream
? Outside open
event?
docs/gridfs-bucket-integration.md
Outdated
uploadStream | ||
.on('error', (err) => { | ||
console.error(err); | ||
self.unlink(await this.collection.findOneAsync(file._id), versionName); | ||
}) | ||
.on('finish', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we register these events when uploadStream
variable created and before passing it to pipe
?
docs/gridfs-bucket-integration.md
Outdated
[property]: uploadStream.id.toHexString(), | ||
}, | ||
}) | ||
self.unlink(await this.collection.findOneAsync(file._id), versionName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got to update to new await unlinkAsync
@harryadel lmk if we can push this one through, I'm finishing with docs |
@dr-dimitru Ok, I'll look at today so we can finalize it. 👍 |
Hey @dr-dimitru, please re-check I took time because I wanted to do this in an example app to verify that our changes are indeed correct and not fix some imaginary code. The test repo is here in case you wanna check it out or even include as an example. |
Hello this is a problem I ran into during our migration and I thought it'd be nice to document so others could avoid this pitfall.
First off, the internal API for objectId got changed. Meteor even caught on this and updated their code.
Second, there was a silent fail with this piece of code:
ver
is undefined so it fails to associate the new gridFS instance. Maybe due to internal mongo versions problem. The code had to be modified so the the gridFS id is stored in the return value of openUploadStream