I'm trying to read a video file from MongoDB using GridFS in GoLang. This is my code snippet,
videoIDHex := bson.ObjectIdHex("5966e9ca0531713218127ddd")
file, err := mongoDatabase.GridFS("collection_files").OpenId(bson.M{"_id": videoIDHex})
if err != nil {
log.Println("Error finding the video : ", err)
}
When I ran it I always got the error,
not found
But, when I tried using find it works fine. I can able to get the document by,
videoIDHex := bson.ObjectIdHex("5966e9ca0531713218127ddd")
collection := mongoDatabase.C("collection_files")
var file interface{}
collection.Find(bson.M{"_id": videoIDHex}).One(&file)
log.Println("file : ", file)
So, how can I solve the issue with GridFS OpenId? If it's solved, I can able to put the GridFS file to buffer and can finally stream it.