Package com.mongodb.gridfs
Class GridFSFile
java.lang.Object
com.mongodb.gridfs.GridFSFile
- All Implemented Interfaces:
- DBObject,- BSONObject
- Direct Known Subclasses:
- GridFSDBFile,- GridFSInputFile
The abstract class representing a GridFS file.
- MongoDB documentation
- GridFS
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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.Gets the file metadata.Gets the upload date.booleankeySet()voidintReturns the number of chunks that store the file data.voidvoidputAll(BSONObject o) removeField(String key) voidsave()Saves the file entry to the files collectionprotected voidSets the GridFS associated with this file.voidsetMetaData(DBObject metadata) Gets the file metadata.Map<?,?> toMap()toString()
- 
Constructor Details- 
GridFSFilepublic GridFSFile()
 
- 
- 
Method Details- 
savepublic void save()Saves the file entry to the files collection- Throws:
- MongoException- if there's a failure
 
- 
numChunkspublic int numChunks()Returns the number of chunks that store the file data.- Returns:
- number of chunks
 
- 
getIdGets the id.- Returns:
- the id of the file.
 
- 
getFilenameGets the filename.- Returns:
- the name of the file
 
- 
getContentTypeGets the content type.- Returns:
- the content type
 
- 
getLengthpublic long getLength()Gets the file's length.- Returns:
- the length of the file
 
- 
getChunkSizepublic long getChunkSize()Gets the size of a chunk.- Returns:
- the chunkSize
 
- 
getUploadDateGets the upload date.- Returns:
- the date
 
- 
getAliasesGets the aliases from the metadata. note: to set aliases, callput(String, Object)with"aliases" , List<String>.- Returns:
- list of aliases
 
- 
getMetaDataGets the file metadata.- Returns:
- the metadata
 
- 
setMetaDataGets the file metadata.- Parameters:
- metadata- metadata to be set
 
- 
put- Specified by:
- putin interface- BSONObject
 
- 
get- Specified by:
- getin interface- BSONObject
 
- 
containsField- Specified by:
- containsFieldin interface- BSONObject
 
- 
keySet- Specified by:
- keySetin interface- BSONObject
 
- 
isPartialObjectpublic boolean isPartialObject()- Specified by:
- isPartialObjectin interface- DBObject
 
- 
markAsPartialObjectpublic void markAsPartialObject()- Specified by:
- markAsPartialObjectin interface- DBObject
 
- 
toString
- 
setGridFSSets the GridFS associated with this file.- Parameters:
- fs- gridFS instance
 
- 
getGridFSGets the GridFS associated with this file- Returns:
- gridFS instance
 
- 
putAll- Specified by:
- putAllin interface- BSONObject
 
- 
putAll- Specified by:
- putAllin interface- BSONObject
 
- 
toMap- Specified by:
- toMapin interface- BSONObject
 
- 
removeField- Specified by:
- removeFieldin interface- BSONObject
 
 
-