

Uncomment the below line and comment the UploadFile above this line to download the file Ioutil.WriteFile(fileName, buf.Bytes(), 0600)įile := os.Args //os.Args = testfile.zip func InitiateMongoClient() *mongo.Client ).Decode(&results)ĭStream, err := bucket.DownloadToStreamByName(fileName, &buf)įmt.Printf("File size to download: %v\n", dStream) Next up is to connect to the cluster, let’s create a function that will initiate the connection. There are plenty of alternative text editors or IDEs to choose form such Atom, GoLand by JetBrain, Sublime Text feel free to choose the one that you feel comfortable with. VS Code is not the only editor that can be used.

Since the text editor used in this tutorial is VS Code, the rest of the dependencies will be added (imported) automatically (which is being taken care of by the VS Code Go extension). Get dependencies go get go./mongo-driver/mongo In this tutorial, we are going to use the binary file of VS Code which is renamed to testfile.zip)


When you want to access information from portions of large files without having to load files into memory, you can use GridFS to recall sections of files without reading the entire file into memory.If your filesystem limits the number of files in a directory, you can use GridFS to store as many files as needed.In this tutorial, we’re going to look at how to use the MongoDB GridFS feature to store files which are larger than 16 MB. This post is a continuity of getting started with Go and MongoDB series using the official Go driver.
