com.mongodb.gridfs
Class GridFS

java.lang.Object
  extended by com.mongodb.gridfs.GridFS

public class GridFS
extends Object

Implementation of GridFS v1.0 GridFS 1.0 spec


MongoDB Doc Links

Field Summary
protected  String _bucketName
           
protected  DBCollection _chunkCollection
           
protected  DB _db
           
protected  DBCollection _filesCollection
           
static String DEFAULT_BUCKET
           
static int DEFAULT_CHUNKSIZE
           
 
Constructor Summary
GridFS(DB db)
          Creates a GridFS instance for the default bucket "fs" in the given database.
GridFS(DB db, String bucket)
          Creates a GridFS instance for the specified bucket in the given database.
 
Method Summary
 GridFSInputFile createFile(byte[] data)
          after calling this method, you have to call save() on the GridFSInputFile file
 GridFSInputFile createFile(File f)
          after calling this method, you have to call save() on the GridFSInputFile file
 GridFSInputFile createFile(InputStream in)
          after calling this method, you have to call save() on the GridFSInputFile file
 GridFSInputFile createFile(InputStream in, String filename)
          after calling this method, you have to call save() on the GridFSInputFile file on that, you can call setFilename, setContentType and control meta data by modifying the result of getMetaData
 List<GridFSDBFile> find(DBObject query)
           
 GridFSDBFile find(ObjectId id)
           
 List<GridFSDBFile> find(String filename)
           
 GridFSDBFile findOne(DBObject query)
           
 GridFSDBFile findOne(ObjectId id)
           
 GridFSDBFile findOne(String filename)
           
 String getBucketName()
           
 DB getDB()
           
 DBCursor getFileList()
          Returns a cursor for this filestore
 DBCursor getFileList(DBObject query)
          Returns a cursor for this filestore
 void remove(DBObject query)
           
 void remove(ObjectId id)
           
 void remove(String filename)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CHUNKSIZE

public static final int DEFAULT_CHUNKSIZE
See Also:
Constant Field Values

DEFAULT_BUCKET

public static final String DEFAULT_BUCKET
See Also:
Constant Field Values

_db

protected final DB _db

_bucketName

protected final String _bucketName

_filesCollection

protected final DBCollection _filesCollection

_chunkCollection

protected final DBCollection _chunkCollection
Constructor Detail

GridFS

public GridFS(DB db)
Creates a GridFS instance for the default bucket "fs" in the given database.

Parameters:
db - database to work with

GridFS

public GridFS(DB db,
              String bucket)
Creates a GridFS instance for the specified bucket in the given database.

Parameters:
db - database to work with
bucket - bucket to use in the given database
Method Detail

getFileList

public DBCursor getFileList()
Returns a cursor for this filestore

Returns:
cursor of file objects

getFileList

public DBCursor getFileList(DBObject query)
Returns a cursor for this filestore

Parameters:
query - filter to apply
Returns:
cursor of file objects

find

public GridFSDBFile find(ObjectId id)

findOne

public GridFSDBFile findOne(ObjectId id)

findOne

public GridFSDBFile findOne(String filename)

findOne

public GridFSDBFile findOne(DBObject query)

find

public List<GridFSDBFile> find(String filename)

find

public List<GridFSDBFile> find(DBObject query)

remove

public void remove(ObjectId id)

remove

public void remove(String filename)

remove

public void remove(DBObject query)

createFile

public GridFSInputFile createFile(byte[] data)
after calling this method, you have to call save() on the GridFSInputFile file


createFile

public GridFSInputFile createFile(File f)
                           throws IOException
after calling this method, you have to call save() on the GridFSInputFile file

Throws:
IOException

createFile

public GridFSInputFile createFile(InputStream in)
after calling this method, you have to call save() on the GridFSInputFile file


createFile

public GridFSInputFile createFile(InputStream in,
                                  String filename)
after calling this method, you have to call save() on the GridFSInputFile file on that, you can call setFilename, setContentType and control meta data by modifying the result of getMetaData


getBucketName

public String getBucketName()

getDB

public DB getDB()