Store and Retrieve Large Files with GridFS
Explore how to manage large files in MongoDB using GridFS, which divides files into chunks stored across collections. Understand when to use GridFS, how to query file sections, and utilize mongofiles for CRUD operations on large file storage.
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:
- Metadata collection:
fs.files - 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 ...