MongoDB Tutorial - MongoDB GridFS








GridFS from MongoDB is used for storing and retrieving large files such as images, audio files, video files, etc.

GridFS can store files greater than its document size limit of 16MB.

GridFS divides a file into chunks and stores each chunk in a separate document, each of maximum size 255k.

Syntax

The following code shows how to add a mp3 file to GridFS.

>mongofiles.exe -d gridfs put song.mp3

gridfs is the name of the database. If the database is not present, MongoDB will automatically create a new document on the fly.

To see the file's document in database, use find query:

>db.fs.files.find()