MONGOC_GRIDFS..._UPLOAD_STREAM(3)

πŸ’… MONGOC_GRIDFS..._UPLOAD_STREAM(3) πŸ’…

okay so bestie, this one lives in libmongoc (that's the C driver for MongoDB, mwah) and it's the function page for mongoc_gridfs_bucket_open_upload_stream. yes the title is lowkey truncated with those dots, that's just how the man page wears its name, don't come for her πŸ’€


🌸 SYNOPSIS 🌸

mongoc_stream_t *
mongoc_gridfs_bucket_open_upload_stream (mongoc_gridfs_bucket_t *bucket,
                                         const char *filename,
                                         const bson_t *opts,
                                         bson_value_t *file_id,
                                         bson_error_t *error);

like, that's the whole signature, no cap ✨


πŸŽ€ PARAMETERS πŸŽ€

  • bucket β€” a mongoc_gridfs_bucket_t. the main character of this whole operation 🫢
  • filename β€” the name of the file you're creating. literally what it'll be called.
  • opts β€” a bson_t or NULL. optional vibes only.
  • file_id β€” a bson_value_t that receives the generated id of the file, or NULL if you can't even be bothered πŸ™ˆ
  • error β€” a bson_error_t to receive any error, or NULL. your little error catcher 🌈

opts may be NULL or a BSON document with additional command options:

  • chunkSizeBytes β€” an int32 chunk size to use for this file. Overrides the chunkSizeBytes set on bucket. so like, it takes priority, periodt πŸ‘‘
  • metadata β€” a bson_t representing metadata to include with the file. the extra lore ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

Opens a stream for writing to a new file in GridFS. That's the whole plot 🎬

The file id is generated automatically β€” the universe picks it for you, slay πŸ’«

To specify an explicit file id, use mongoc_gridfs_bucket_open_upload_stream_with_id(). iykyk, different function, different page.


⭐ RETURNS ⭐

A mongoc_stream_t that can be written to, or NULL on failure. so like, vibe check the return value, bestie β€” NULL means it did not eat 😭

Errors on this stream can be retrieved with mongoc_gridfs_bucket_stream_error(). go get your diagnostics, they're right there.

After calling mongoc_stream_close() the file is completely written in GridFS. that's the moment. the final girl moment. πŸ’…

fr fr though: the file isn't fully written until you hit mongoc_stream_close(), so don't go celebrating early πŸ”₯

πŸ‘€ SEE ALSO:

  • mongoc_gridfs_bucket_open_upload_stream_with_id()
  • mongoc_gridfs_bucket_stream_error()

πŸ’œ AUTHOR πŸ’œ

MongoDB, Inc β€” the icons who made this ✨

2009-present, MongoDB, Inc. all theirs, we're just reading it πŸ’–


and that's the tea πŸ“ β€” this page is from libmongoc version 2.5.6, dated Oct 09, 2026. screenshot it, bookmark it, tell your friends, mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from