top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is Grid File System (GridFS) and how does it work for mongoDB ?

+1 vote
482 views
What is Grid File System (GridFS) and how does it work for mongoDB ?
posted Jun 15, 2015 by Vikram Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes

GridFS or Grid File System is a mongoDB specification. which is basically used for storing and retrieving the document exceed the BSON-document or mongoDB-document size limit of 16MB.

GridFS stores a file into parts known as chunks of size 255k and each chunk saved on separate document. it is an abstraction of simple file system on top of mongoDB. By default it uses two collections fs.files and fs.chunks in order to store the files metadata and chunks. Each chunk is identified by its unique _id ObjectId field. The fs.files serve as a parent document. The files_id field in the fs.chunks document links the chunk to its parent.

fs.files collection

{
   "filename": "test.txt",
   "chunkSize": NumberInt(261120),
   "uploadDate": ISODate("2014-04-13T11:32:33.557Z"),
   "md5": "7b762939321e146569b07f72c62cca4f",
   "length": NumberInt(646)
}

fs.chunks

{
   "files_id": ObjectId("534a75d19f54bfec8a2fe44b"),
   "n": NumberInt(0),
   "data": "Mongo Binary Data"
}
answer Jun 15, 2015 by Prakash Singh
...