MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
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
 
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
 
void removeFile (const std::string &fileName)
 removes file referenced by fileName from the db
 
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

◆ GridFS()

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

◆ removeFile()

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

◆ setChunkSize()

void mongo::GridFS::setChunkSize ( unsigned int  size)
Parameters

◆ storeFile() [1/2]

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

◆ storeFile() [2/2]

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

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