Question

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;)

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top