|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.mongodb.gridfs.GridFS
public class GridFS
Implementation of GridFS v1.0 GridFS 1.0 spec
| Field Summary | |
|---|---|
protected java.lang.String |
_bucketName
|
protected DBCollection |
_chunkCollection
|
protected DB |
_db
|
protected DBCollection |
_filesCollection
|
static java.lang.String |
DEFAULT_BUCKET
bucket to use for the collection namespaces |
static int |
DEFAULT_CHUNKSIZE
file's chunk size |
| 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()
This method creates an empty GridFSInputFile instance. |
GridFSInputFile |
createFile(byte[] data)
creates a file entry. |
GridFSInputFile |
createFile(java.io.File f)
creates a file entry. |
GridFSInputFile |
createFile(java.io.InputStream in)
creates a file entry. |
GridFSInputFile |
createFile(java.io.InputStream in,
java.lang.String filename)
creates a file entry. |
GridFSInputFile |
createFile(java.lang.String filename)
|
java.util.List<GridFSDBFile> |
find(DBObject query)
finds a list of files matching the given query |
GridFSDBFile |
find(ObjectId id)
finds one file matching the given id. |
java.util.List<GridFSDBFile> |
find(java.lang.String filename)
finds a list of files matching the given filename |
GridFSDBFile |
findOne(DBObject query)
finds one file matching the given query |
GridFSDBFile |
findOne(ObjectId id)
finds one file matching the given id. |
GridFSDBFile |
findOne(java.lang.String filename)
finds one file matching the given filename |
java.lang.String |
getBucketName()
gets the bucket name used in the collection's namespace |
DB |
getDB()
gets the db used |
DBCursor |
getFileList()
gets the list of files stored in this gridfs, sorted by filename |
DBCursor |
getFileList(DBObject query)
gets a filtered list of files stored in this gridfs, sorted by filename |
void |
remove(DBObject query)
removes all files matching the given query |
void |
remove(ObjectId id)
removes the file matching the given id |
void |
remove(java.lang.String filename)
removes all files matching the given filename |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_CHUNKSIZE
public static final java.lang.String DEFAULT_BUCKET
protected final DB _db
protected final java.lang.String _bucketName
protected final DBCollection _filesCollection
protected final DBCollection _chunkCollection
| Constructor Detail |
|---|
public GridFS(DB db)
db - database to work with
public GridFS(DB db,
java.lang.String bucket)
db - database to work withbucket - bucket to use in the given database| Method Detail |
|---|
public DBCursor getFileList()
public DBCursor getFileList(DBObject query)
query - filter to apply
public GridFSDBFile find(ObjectId id)
id -
public GridFSDBFile findOne(ObjectId id)
id -
public GridFSDBFile findOne(java.lang.String filename)
filename -
public GridFSDBFile findOne(DBObject query)
query -
public java.util.List<GridFSDBFile> find(java.lang.String filename)
filename -
public java.util.List<GridFSDBFile> find(DBObject query)
query -
public void remove(ObjectId id)
id - public void remove(java.lang.String filename)
filename - public void remove(DBObject query)
query - public GridFSInputFile createFile(byte[] data)
data - the file's data
public GridFSInputFile createFile(java.io.File f)
throws java.io.IOException
f - the file object
java.io.IOExceptionpublic GridFSInputFile createFile(java.io.InputStream in)
in - an inputstream containing the file's data
public GridFSInputFile createFile(java.io.InputStream in,
java.lang.String filename)
in - an inputstream containing the file's datafilename - the file name as stored in the db
public GridFSInputFile createFile(java.lang.String filename)
filename - the file name as stored in the db
GridFS#createFile()} on how to use this methodpublic GridFSInputFile createFile()
GridFSInputFile instance. On this
instance an OutputStream can be obtained using the
GridFSInputFile.getOutputStream() method. You can still call
GridFSInputFile.setContentType(String) and
GridFSInputFile.setFilename(String). The file will be completely
written and closed after calling the OutputStream.close()
method on the output stream.
public java.lang.String getBucketName()
public DB getDB()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||