Skip to content

Commit

Permalink
Merge pull request #16 from JSAssassin/fix-upload-method
Browse files Browse the repository at this point in the history
Fix bug where file is undefined on finish in newer mongodb versions
  • Loading branch information
abskmj committed May 29, 2024
2 parents 45d4701 + 749f353 commit 9bcde88
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/gridFile.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ schema.method('upload', function (stream, callback) {
})

uploadStream.on('finish', (file) => {
if(!file) {
file = uploadStream.gridFSFile
}
const document = this.model.hydrate(file)

resolve(document)
Expand Down

0 comments on commit 9bcde88

Please sign in to comment.