Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB GridFS bucket?

I work with MongoDB C# Samus driver.

One of constructors of class MongoDB.GridFS.GridFile has parameter "bucket". When i create GridFile in Java like example i cannot set this "bucket". But i can set this "bucket" in Java when create GridFS object Java documentation. I'm confused!

My question:

What is "bucket"? For what? Tell please some use cases;)

like image 542
Edward83 Avatar asked Dec 12 '22 18:12

Edward83


1 Answers

Bucket is base name for files and chunks collections. By default bucket is 'fs' so you will have two collections:

  • fs.files will store file properties like id, name, size, chunk size, md5 checksum etc.
  • fs.chunks will store the actual binary data split into chunks, one per document.

Using GridFS class constructor argument you can set arbitrary bucket name.

Different buckets can be useful if you need to have separate collections for different types of files, so you can apply different indexes, sharding etc.

like image 87
pingw33n Avatar answered Dec 27 '22 09:12

pingw33n