MONGOC_GRIDFS_BUCKET_NEW(3)

✨ mongoc_gridfs_bucket_new(3) ✨

okay bestie, welcome to the libmongoc manual, and today's main character is mongoc_gridfs_bucket_new πŸ’… she's your gateway to GridFS and honestly? iconic.


🌸 SYNOPSIS 🌸

mongoc_gridfs_bucket_t *
mongoc_gridfs_bucket_new (mongoc_database_t *db,
                          const bson_t *opts,
                          const mongoc_read_prefs_t *read_prefs,
                          bson_error_t* error);

πŸŽ€ PARAMETERS πŸŽ€

  • db β€” a mongoc_database_t. the database she's gonna live in πŸ’–
  • opts β€” a bson_t or NULL.
  • read_prefs β€” a mongoc_read_prefs_t used for read operations, or NULL to inherit read preferences from db 🫢
  • error β€” a bson_error_t or NULL.

so opts can be NULL, or it can be a whole BSON document stuffed with extra command options, and those are:

  • bucketName β€” a UTF-8 string used as the prefix to the GridFS "chunks" and "files" collections. defaults to "fs". ⚠️ heads up: the bucket name, together with the database and suffix collections, must not exceed 120 characters. see the manual for the max namespace length, iykyk.
  • chunkSizeBytes β€” an int32 representing the chunk size. defaults to 255KB πŸ“
  • writeConcern β€” construct a mongoc_write_concern_t and use mongoc_write_concern_append() to add the write concern to opts. see the example code for mongoc_client_write_command_with_opts().
  • readConcern β€” construct a mongoc_read_concern_t and use mongoc_read_concern_append() to add the read concern to opts. see the example code for mongoc_client_read_command_with_opts(). read concern requires MongoDB 3.2 or later, otherwise an error is returned 😭 no cap.

πŸ¦‹ DESCRIPTION πŸ¦‹

creates a new mongoc_gridfs_bucket_t. use this handle to perform GridFS operations. that's it, that's the vibe ✨


πŸ‘‘ RETURNS πŸ‘‘

a newly allocated mongoc_gridfs_bucket_t that should be freed with mongoc_gridfs_bucket_destroy(), or NULL on failure πŸ’€ don't forget the destroy, bestie, she's not gonna free herself.


🌈 AUTHOR 🌈

MongoDB, Inc

2009-present, MongoDB, Inc.


and that's the whole page, periodt πŸŽ€ this was libmongoc version 2.5.6, dated Oct 09, 2026 β€” go slay your GridFS buckets fr fr πŸ’…βœ¨

πŸ“¦ where this page comes from