com.mongodb.gridfs
Class GridFS

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

public class GridFS
extends java.lang.Object

Implementation of GridFS v1.0 GridFS 1.0 spec


MongoDB Doc Links

Field Summary
protected  java.lang.String _bucketName
           
protected  DBCollection _chunkCollection
           
protected  DB _db
           
protected  DBCollection _filesCollection
           
static java.lang.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, java.lang.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(java.io.File f)
          after calling this method, you have to call save() on the GridFSInputFile file
 GridFSInputFile createFile(java.io.InputStream in)
          after calling this method, you have to call save() on the GridFSInputFile file
 GridFSInputFile createFile(java.io.InputStream in, java.lang.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
 java.util.List<GridFSDBFile> find(DBObject query)
           
 GridFSDBFile find(ObjectId id)
           
 java.util.List<GridFSDBFile> find(java.lang.String filename)
           
 GridFSDBFile findOne(DBObject query)
           
 GridFSDBFile findOne(ObjectId id)
           
 GridFSDBFile findOne(java.lang.String filename)
           
 java.lang.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(java.lang.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 java.lang.String DEFAULT_BUCKET
See Also:
Constant Field Values

_db

protected final DB _db

_bucketName

protected final java.lang.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,
              java.lang.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(java.lang.String filename)

findOne

public GridFSDBFile findOne(DBObject query)

find

public java.util.List<GridFSDBFile> find(java.lang.String filename)

find

public java.util.List<GridFSDBFile> find(DBObject query)

remove

public void remove(ObjectId id)

remove

public void remove(java.lang.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(java.io.File f)
                           throws java.io.IOException
after calling this method, you have to call save() on the GridFSInputFile file

Throws:
java.io.IOException

createFile

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


createFile

public GridFSInputFile createFile(java.io.InputStream in,
                                  java.lang.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 java.lang.String getBucketName()

getDB

public DB getDB()