Workspace 6.21.5
Public Member Functions | List of all members
Gridfs Class Reference

Wrapper of mongoc_gridfs_t.

#include <Distributed/mongocxx.h>

Public Member Functions

 Gridfs (Collection &collection, int bufferSize=102400)
 
virtual ~Gridfs ()
 
mongoc_gridfs_t *& get ()
 
const mongoc_gridfs_t * get () const
 
mongoc_collection_t * getCollection () const
 
QList< QPair< QString, QString > > getList () const
 Return a sorted list of all pairs <file name, file id> in GridFs.
 
qint64 readFrom (const QString &fileId, QString &fileName, QByteArray &byteArray) const
 Read a GridFs file specified by fileId to a byteArray. The file name will be returned in fileName.
 
qint64 writeTo (QString &fileId, const QString &fileName, QByteArray &byteArray) const
 Write byteArray to a GridFs file specified by fileId. If the file exists then it will be truncated, otherwise a new file will be created. If fileId is left empty then a new file will be created and a new file ID (generated by GridFs) will be returned to fileId. The file name in GridFs will be set to fileName.
 

Constructor & Destructor Documentation

◆ Gridfs()

Gridfs ( Collection collection,
int  bufferSize = 102400 
)

◆ ~Gridfs()

~Gridfs ( )
virtual

Member Function Documentation

◆ get() [1/2]

mongoc_gridfs_t *& get ( )

◆ get() [2/2]

const mongoc_gridfs_t * get ( ) const

◆ getCollection()

mongoc_collection_t * getCollection ( ) const

◆ getList()

QList< QPair< QString, QString > > getList ( ) const
Returns
Sorted list of all pairs <file name, file id> in GridFs.

◆ readFrom()

qint64 readFrom ( const QString &  fileId,
QString &  fileName,
QByteArray &  byteArray 
) const
Parameters
fileId[in] The file ID used to specify the file read.
fileName[out] The returned file name.
byteArray[out] The data.
Returns
The number of bytes actually read from the GridFs file, or -1 on error.

◆ writeTo()

qint64 writeTo ( QString &  fileId,
const QString &  fileName,
QByteArray &  byteArray 
) const
Parameters
fileId[in/out] The file ID used to specified the file written to or containing a new uniquely generated file ID if left empty.
fileName[in] The file name. Notice that different files with same name can exist in GridFs. The existing file will be renamed.
byteArray[in] The data.
Returns
The number of bytes actually written to the GridFs file, or -1 on error.