MONGOC_GRIDFS...AD_FROM_STREAM(3)

πŸ’… MONGOC_GRIDFS_BUCKET_UPLOAD_FROM_STREAM(3) πŸ’…

okay so bestie, welcome to libmongoc β€” yes that's the manual we're living in right now, and today's main character is mongoc_gridfs_bucket_upload_from_stream(). she uploads. she streams. she slays. let's get into it 🫢


✨ SYNOPSIS ✨

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

πŸŽ€ PARAMETERS πŸŽ€

  • bucket β€” a mongoc_gridfs_bucket_t. the bucket in question. iconic.
  • filename β€” the name of the file to create. name her, girl.
  • source β€” a mongoc_stream_t used as the source of the data to upload. this is where the bytes come from, no cap.
  • opts β€” a bson_t or NULL. literally optional, like your third coffee.
  • file_id β€” a bson_value_t to receive the generated id of the file, or NULL. she'll hand you the id if you give her somewhere to put it 🌸
  • error β€” a bson_error_t to receive any error, or NULL. give her a place to vent or she'll keep it inside 😭

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. yes, she overrides. she's that girl.
  • metadata β€” a bson_t representing metadata to include with the file. receipts, basically. πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

reads from the source stream and writes to a new file in GridFS. the file id is generated automatically β€” the way that she just does that? obsessed.

need a specific file id instead? use mongoc_gridfs_bucket_upload_from_stream_with_id() β€” that's her sister, also iconic.

she reads from the source stream using mongoc_stream_read() until the return value indicates end-of-file. that's it. that's the whole vibe check. ⭐

important, bestie: the source stream is not closed after calling mongoc_gridfs_bucket_upload_from_stream(). you gotta call mongoc_stream_close() after. she's not gonna do it for you, she's not your mom 🫢

πŸ”₯ RETURNS πŸ”₯

True if the operation succeeded. False otherwise β€” and in that case she sets error. fr fr.

πŸ’« SEE ALSO πŸ’«

  • mongoc_stream_file_new() and mongoc_stream_file_new_for_path() β€” these can be used to create a source stream from a file. like, if you needed a source stream from a file. iykyk 😌

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc

2009-present, MongoDB, Inc.


okay that's the whole page!! she's giving documentation, she's giving library energy πŸ’œ this was libmongoc, version 2.5.6, dated ever so iconically as Oct 09, 2026 β€” go forth and upload from a stream, bestie, and don't forget to close that stream. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from