Skip to content

Commit 385f1a6

Browse files
patrickfreedskriptble
authored andcommitted
GODRIVER-887 Properly set default registry when using UploadOptions
1 parent 93a85d7 commit 385f1a6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

mongo/gridfs/bucket.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,9 @@ func (b *Bucket) parseUploadOptions(opts ...*options.UploadOptions) (*Upload, er
526526
if uo.ChunkSizeBytes != nil {
527527
upload.chunkSize = *uo.ChunkSizeBytes
528528
}
529+
if uo.Registry == nil {
530+
uo.Registry = bson.DefaultRegistry
531+
}
529532
if uo.Metadata != nil {
530533
raw, err := bson.MarshalWithRegistry(uo.Registry, uo.Metadata)
531534
if err != nil {

mongo/options/gridfsoptions.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package options
99
import (
1010
"time"
1111

12+
"go.mongodb.org/mongo-driver/bson"
1213
"go.mongodb.org/mongo-driver/bson/bsoncodec"
1314
"go.mongodb.org/mongo-driver/mongo/readconcern"
1415
"go.mongodb.org/mongo-driver/mongo/readpref"
@@ -111,7 +112,7 @@ type UploadOptions struct {
111112

112113
// GridFSUpload creates a new *UploadOptions
113114
func GridFSUpload() *UploadOptions {
114-
return &UploadOptions{}
115+
return &UploadOptions{Registry: bson.DefaultRegistry}
115116
}
116117

117118
// SetChunkSizeBytes sets the chunk size in bytes for the upload. Defaults to 255KB if not set.

0 commit comments

Comments
 (0)