- MongoDB C Driver 1.13.1 »
- API Reference »
- mongoc_gridfs_t

# mongoc_gridfs_create_file_from_stream()

## 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.

Created using Sphinx 1.8.3, based on Sphinx Readable Theme.