MongoDB C++ Driver  legacy-1.1.2
Public Member Functions | List of all members
mongo::GridFS Class Reference

GridFS is for storing large file-style objects in MongoDB. More...

#include <gridfs.h>

Public Member Functions

 GridFS (DBClientBase &client, const std::string &dbName, const std::string &prefix="fs")
 
void setChunkSize (unsigned int size)
 
BSONObj storeFile (const std::string &fileName, const std::string &remoteName="", const std::string &contentType="")
 puts the file reference by fileName into the db More...
 
BSONObj storeFile (const char *data, size_t length, const std::string &remoteName, const std::string &contentType="")
 puts the file represented by data into the db More...
 
void removeFile (const std::string &fileName)
 removes file referenced by fileName from the db More...
 
GridFile findFile (Query query) const
 returns a file object matching the query
 
GridFile findFileByName (const std::string &fileName) const
 equiv to findFile( { filename : filename } )
 
std::auto_ptr< DBClientCursorlist () const
 convenience method to get all the files
 
std::auto_ptr< DBClientCursorlist (BSONObj query) const
 convenience method to get all the files with a filter
 

Detailed Description

GridFS is for storing large file-style objects in MongoDB.

See also
http://dochub.mongodb.org/core/gridfsspec

Constructor & Destructor Documentation

mongo::GridFS::GridFS ( DBClientBase client,
const std::string &  dbName,
const std::string &  prefix = "fs" 
)
Parameters
client- db connection
dbName- root database name
prefix- if you want your data somewhere besides <dbname>.fs

Member Function Documentation

void mongo::GridFS::removeFile ( const std::string &  fileName)

removes file referenced by fileName from the db

Parameters
fileNamefilename (in GridFS) of the file to remove
Returns
the file object
void mongo::GridFS::setChunkSize ( unsigned int  size)
Parameters
BSONObj mongo::GridFS::storeFile ( const std::string &  fileName,
const std::string &  remoteName = "",
const std::string &  contentType = "" 
)

puts the file reference by fileName into the db

Parameters
fileNamelocal filename relative to process
remoteNameoptional filename to use for file stored in GridFS (default is to use fileName parameter)
contentTypeoptional MIME type for this object. (default is to omit)
Returns
the file object
BSONObj mongo::GridFS::storeFile ( const char *  data,
size_t  length,
const std::string &  remoteName,
const std::string &  contentType = "" 
)

puts the file represented by data into the db

Parameters
datapointer to buffer to store in GridFS
lengthlength of buffer
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: