|
||||||||||
| 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 String |
_bucketName
|
protected DBCollection |
_chunkCollection
|
protected DB |
_db
|
protected DBCollection |
_filesCollection
|
static String |
DEFAULT_BUCKET
bucket to use for the collection namespaces |
static int |
DEFAULT_CHUNKSIZE
file's chunk size |
static long |
MAX_CHUNKSIZE
file's max chunk size |
| 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 | |
|---|---|
protected GridFSDBFile |
_fix(Object o)
|
GridFSInputFile |
createFile()
This method creates an empty GridFSInputFile instance. |
GridFSInputFile |
createFile(byte[] data)
creates a file entry. |
GridFSInputFile |
createFile(File f)
creates a file entry. |
GridFSInputFile |
createFile(InputStream in)
creates a file entry. |
GridFSInputFile |
createFile(InputStream in,
boolean closeStreamOnPersist)
creates a file entry. |
GridFSInputFile |
createFile(InputStream in,
String filename)
creates a file entry. |
GridFSInputFile |
createFile(InputStream in,
String filename,
boolean closeStreamOnPersist)
creates a file entry. |
GridFSInputFile |
createFile(String filename)
|
List<GridFSDBFile> |
find(DBObject query)
finds a list of files matching the given query |
List<GridFSDBFile> |
find(DBObject query,
DBObject sort)
finds a list of files matching the given query |
GridFSDBFile |
find(ObjectId id)
finds one file matching the given id. |
List<GridFSDBFile> |
find(String filename)
finds a list of files matching the given filename |
List<GridFSDBFile> |
find(String filename,
DBObject sort)
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(String filename)
finds one file matching the given filename |
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 |
DBCursor |
getFileList(DBObject query,
DBObject sort)
gets a filtered list of files stored in this gridfs, sorted by param sort |
void |
remove(DBObject query)
removes all files matching the given query |
void |
remove(ObjectId id)
removes the file matching the given id |
void |
remove(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 long MAX_CHUNKSIZE
public static final String DEFAULT_BUCKET
protected final DB _db
protected final String _bucketName
protected final DBCollection _filesCollection
protected final DBCollection _chunkCollection
| Constructor Detail |
|---|
public GridFS(DB db)
db - database to work with
MongoExceptionWriteConcern
public GridFS(DB db,
String bucket)
db - database to work withbucket - bucket to use in the given database
MongoExceptionWriteConcern| Method Detail |
|---|
public DBCursor getFileList()
public DBCursor getFileList(DBObject query)
query - filter to apply
public DBCursor getFileList(DBObject query,
DBObject sort)
query - filter to applysort - sorting to apply
public GridFSDBFile find(ObjectId id)
id -
MongoExceptionpublic GridFSDBFile findOne(ObjectId id)
id -
MongoExceptionpublic GridFSDBFile findOne(String filename)
filename -
MongoExceptionpublic GridFSDBFile findOne(DBObject query)
query -
MongoExceptionpublic List<GridFSDBFile> find(String filename)
filename -
MongoException
public List<GridFSDBFile> find(String filename,
DBObject sort)
filename - sort -
MongoExceptionpublic List<GridFSDBFile> find(DBObject query)
query -
MongoException
public List<GridFSDBFile> find(DBObject query,
DBObject sort)
query - sort -
MongoExceptionprotected GridFSDBFile _fix(Object o)
public void remove(ObjectId id)
id -
MongoExceptionpublic void remove(String filename)
filename -
MongoExceptionpublic void remove(DBObject query)
query -
MongoExceptionpublic GridFSInputFile createFile(byte[] data)
data - the file's data
public GridFSInputFile createFile(File f)
throws IOException
f - the file object
IOExceptionpublic GridFSInputFile createFile(InputStream in)
in - an inputstream containing the file's data
public GridFSInputFile createFile(InputStream in,
boolean closeStreamOnPersist)
in - an inputstream containing the file's datacloseStreamOnPersist - indicate the passed in input stream should be closed
once the data chunk persisted
public GridFSInputFile createFile(InputStream in,
String filename)
in - an inputstream containing the file's datafilename - the file name as stored in the db
public GridFSInputFile createFile(InputStream in,
String filename,
boolean closeStreamOnPersist)
in - an inputstream containing the file's datafilename - the file name as stored in the dbcloseStreamOnPersist - indicate the passed in input stream should be closed
once the data chunk persisted
public GridFSInputFile createFile(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 String getBucketName()
public DB getDB()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||