---
name: "mongoc_gridfs_bucket_new"
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_bucket_new"
---

# mongoc\_gridfs\_bucket\_new(3)

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

- •

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

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

- •

  **bucketName**: A UTF-8 string used as the prefix to the GridFS "chunks" and "files" collections. Defaults to "fs". The bucket name, together with the database and suffix collections must not exceed 120 characters. See the manual for *the max namespace length*.

- •

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

## DESCRIPTION

Creates a new *mongoc\_gridfs\_bucket\_t*. Use this handle to perform GridFS operations.

## RETURNS

A newly allocated *mongoc\_gridfs\_bucket\_t* that should be freed with *mongoc\_gridfs\_bucket\_destroy()* or **NULL** on failure.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
