MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
mongo::GridFileBuilder Class Reference

class which allow to build GridFiles in a stream fashion way More...

#include <gridfs.h>

Public Member Functions

 GridFileBuilder (GridFS *const grid)
 
void appendChunk (const char *data, size_t length)
 Appends a chunk of data.
 
mongo::BSONObj buildFile (const std::string &remoteName, const std::string &contentType="")
 Inserts the description of the file in GridFS collection.
 

Detailed Description

class which allow to build GridFiles in a stream fashion way

Constructor & Destructor Documentation

◆ GridFileBuilder()

mongo::GridFileBuilder::GridFileBuilder ( GridFS *const  grid)
Parameters
grid- gridfs instance

Member Function Documentation

◆ appendChunk()

void mongo::GridFileBuilder::appendChunk ( const char *  data,
size_t  length 
)

Appends a chunk of data.

Data will be split as many times as necessary in chunkSize blocks. Sizes not multiple of chunkSize will copy the reamining bytes to a pendingData pointer. In this way, it is possible to add data in a stream fashion way.

Parameters
data- C string with data
length- size of the string

◆ buildFile()

mongo::BSONObj mongo::GridFileBuilder::buildFile ( const std::string &  remoteName,
const std::string &  contentType = "" 
)

Inserts the description of the file in GridFS collection.

Note that the stream will be reinitialized after the build call, so it will be possible to continue appending data to build another file.

Parameters
remoteNamefilename to use for file stored in GridFS
contentTypeoptional MIME type for this object. (default is to omit)
Returns
the file object

The documentation for this class was generated from the following file: