MongoDB  2.7.0
Public Member Functions | Friends | 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 string &dbName, const string &prefix="fs")
 
void setChunkSize (unsigned int size)
 
unsigned int getChunkSize () const
 
BSONObj storeFile (const string &fileName, const string &remoteName="", const string &contentType="")
 puts the file reference by fileName into the db More...
 
BSONObj storeFile (const char *data, size_t length, const string &remoteName, const string &contentType="")
 puts the file represented by data into the db More...
 
void removeFile (const string &fileName)
 removes file referenced by fileName from the db More...
 
GridFile findFile (BSONObj query) const
 returns a file object matching the query
 
GridFile findFile (const string &fileName) const
 equiv to findFile( { filename : filename } )
 
auto_ptr< DBClientCursorlist () const
 convenience method to get all the files
 
auto_ptr< DBClientCursorlist (BSONObj query) const
 convenience method to get all the files with a filter
 

Friends

class GridFile
 

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 string &  dbName,
const 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 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 string &  fileName,
const string &  remoteName = "",
const 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 string &  remoteName,
const 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 files: