Hiprup

What is GridFS in MongoDB?

GridFS is MongoDB's spec for storing files larger than the 16 MB document limit. Splits a file into chunks (default 255 KB) and stores them across two collections: fs.files (metadata) and fs.chunks (binary data).

  • When to use — you specifically want files in MongoDB; usually S3 / object storage is a better fit.

  • Range reads — can stream chunks without loading the whole file into memory.

  • Replicated & sharded — benefits from MongoDB's HA story for free.

  • Drivers handle it — Node, Python, Java drivers all expose a GridFS API.

  • Modern preference — store files in object storage, save URLs in MongoDB.

GridFS = file storage for files > 16MB. Two collections: fs.files (metadata) + fs.chunks (binary data). Chunks default to 255KB.

For small files (< 16MB): use BinData in regular documents. For production at scale: S3 + MongoDB references is often better than GridFS.

What is GridFS in MongoDB? | Hiprup