Package com.mongodb.gridfs
Class GridFSFile
java.lang.Object
com.mongodb.gridfs.GridFSFile
- All Implemented Interfaces:
com.mongodb.DBObject,org.bson.BSONObject
- Direct Known Subclasses:
GridFSDBFile,GridFSInputFile
The abstract class representing a GridFS file.
- MongoDB documentation
- GridFS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the aliases from the metadata.longGets the size of a chunk.Gets the content type.Gets the filename.protected GridFSGets the GridFS associated with this filegetId()Gets the id.longGets the file's length.com.mongodb.DBObjectGets the file metadata.Gets the upload date.booleankeySet()voidintReturns the number of chunks that store the file data.voidvoidputAll(org.bson.BSONObject o) removeField(String key) voidsave()Saves the file entry to the files collectionprotected voidSets the GridFS associated with this file.voidsetMetaData(com.mongodb.DBObject metadata) Gets the file metadata.Map<?,?> toMap()toString()
-
Constructor Details
-
GridFSFile
public GridFSFile()
-
-
Method Details
-
save
public void save()Saves the file entry to the files collection- Throws:
com.mongodb.MongoException- if there's a failure
-
numChunks
public int numChunks()Returns the number of chunks that store the file data.- Returns:
- number of chunks
-
getId
Gets the id.- Returns:
- the id of the file.
-
getFilename
Gets the filename.- Returns:
- the name of the file
-
getContentType
Gets the content type.- Returns:
- the content type
-
getLength
public long getLength()Gets the file's length.- Returns:
- the length of the file
-
getChunkSize
public long getChunkSize()Gets the size of a chunk.- Returns:
- the chunkSize
-
getUploadDate
Gets the upload date.- Returns:
- the date
-
getAliases
Gets the aliases from the metadata. note: to set aliases, callput(String, Object)with"aliases" , List<String>.- Returns:
- list of aliases
-
getMetaData
public com.mongodb.DBObject getMetaData()Gets the file metadata.- Returns:
- the metadata
-
setMetaData
public void setMetaData(com.mongodb.DBObject metadata) Gets the file metadata.- Parameters:
metadata- metadata to be set
-
put
- Specified by:
putin interfaceorg.bson.BSONObject
-
get
- Specified by:
getin interfaceorg.bson.BSONObject
-
containsField
- Specified by:
containsFieldin interfaceorg.bson.BSONObject
-
keySet
- Specified by:
keySetin interfaceorg.bson.BSONObject
-
isPartialObject
public boolean isPartialObject()- Specified by:
isPartialObjectin interfacecom.mongodb.DBObject
-
markAsPartialObject
public void markAsPartialObject()- Specified by:
markAsPartialObjectin interfacecom.mongodb.DBObject
-
toString
-
setGridFS
Sets the GridFS associated with this file.- Parameters:
fs- gridFS instance
-
getGridFS
Gets the GridFS associated with this file- Returns:
- gridFS instance
-
putAll
public void putAll(org.bson.BSONObject o) - Specified by:
putAllin interfaceorg.bson.BSONObject
-
putAll
- Specified by:
putAllin interfaceorg.bson.BSONObject
-
toMap
- Specified by:
toMapin interfaceorg.bson.BSONObject
-
removeField
- Specified by:
removeFieldin interfaceorg.bson.BSONObject
-