I'm trying to persist some files in MongoDB. Not interested in GridFS as files are always less than 256KB. It seems difficult to find any good example on how this typically is done.
What I do is open temporary file for reading to get an io.Reader
and use bson.NewFromIOReader(io.Reader)
to read bytes into bson.Raw
type. However I always get an exception unexpected EOF
. After some investigation it seems that this function uses io.ReadFull
which may throw that exception. So I'm wondering what I do wrong. I can perform io.Copy
operation on the same reader without such exception.
Any ideas?