---
name: "mongoc_gridfs_create_file_from_stream"
section: "3"
platform: "linux"
package: "libmongoc-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mongoc_gridfs_create_file_from_stream"
---

# mongoc\_gridfs\_create\_file\_from\_stream(3)

## SYNOPSIS

```
mongoc_gridfs_file_t *
mongoc_gridfs_create_file_from_stream (mongoc_gridfs_t *gridfs,
                                       mongoc_stream_t *stream,
                                       mongoc_gridfs_file_opt_t *opt);
```

## PARAMETERS

- •

  **gridfs**: A *mongoc\_gridfs\_t*.

- •

  **stream**: A *mongoc\_stream\_t*.

- •

  **opt**: A *mongoc\_gridfs\_file\_opt\_t* to specify file options.

## DESCRIPTION

This function shall create a new *mongoc\_gridfs\_file\_t* and fill it with the contents of **stream**. Note that this function will read from **stream** until End of File, making it best suited for file-backed streams.

## RETURNS

A newly allocated *mongoc\_gridfs\_file\_t* that should be freed with *mongoc\_gridfs\_file\_destroy()* when no longer in use. Returns NULL and logs an error message if there is a network or server error writing data to the MongoDB server.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
