...

/

Store and Retrieve Large Files with GridFS

Store and Retrieve Large Files with GridFS

Learn and practice storing and retrieving large files with GridFS.

We'll cover the following...

Why use GridFS

GridFS is a specification used to store large files.

In MongoDB, we cannot store a file larger than 16MB, as that is the maximum document size it allows. We use GridFS to overcome this drawback.

GridFS collections

GridFS uses these two collections to store a file:

  1. Metadata collection: fs.files
  2. File chunks collection: fs.chunks

Metadata collections store the metadata of a file. For a single file, there is one document in the fs.files collection while there could be multiple collections in the fs.chunks collection. File chunks ...