Package com.mongodb.gridfs
Class GridFSFile
- java.lang.Object
-
- com.mongodb.gridfs.GridFSFile
-
- All Implemented Interfaces:
DBObject
,BSONObject
- Direct Known Subclasses:
GridFSDBFile
,GridFSInputFile
public abstract class GridFSFile extends Object implements DBObject
The abstract class representing a GridFS file.- MongoDB documentation
- GridFS
-
-
Constructor Summary
Constructors Constructor Description GridFSFile()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsField(String s)
Object
get(String key)
List<String>
getAliases()
Gets the aliases from the metadata.long
getChunkSize()
Gets the size of a chunk.String
getContentType()
Gets the content type.String
getFilename()
Gets the filename.protected GridFS
getGridFS()
Gets the GridFS associated with this fileObject
getId()
Gets the id.long
getLength()
Gets the file's length.DBObject
getMetaData()
Gets the file metadata.Date
getUploadDate()
Gets the upload date.boolean
isPartialObject()
Set<String>
keySet()
void
markAsPartialObject()
int
numChunks()
Returns the number of chunks that store the file data.Object
put(String key, Object v)
void
putAll(Map m)
void
putAll(BSONObject o)
Object
removeField(String key)
void
save()
Saves the file entry to the files collectionprotected void
setGridFS(GridFS fs)
Sets the GridFS associated with this file.void
setMetaData(DBObject metadata)
Gets the file metadata.Map<?,?>
toMap()
String
toString()
-
-
-
Method Detail
-
save
public void save()
Saves the file entry to the files collection- Throws:
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
public Object getId()
Gets the id.- Returns:
- the id of the file.
-
getFilename
public String getFilename()
Gets the filename.- Returns:
- the name of the file
-
getContentType
public String 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
public Date getUploadDate()
Gets the upload date.- Returns:
- the date
-
getAliases
public List<String> getAliases()
Gets the aliases from the metadata. note: to set aliases, callput(String, Object)
with"aliases" , List<String>
.- Returns:
- list of aliases
-
getMetaData
public DBObject getMetaData()
Gets the file metadata.- Returns:
- the metadata
-
setMetaData
public void setMetaData(DBObject metadata)
Gets the file metadata.- Parameters:
metadata
- metadata to be set
-
put
public Object put(String key, Object v)
- Specified by:
put
in interfaceBSONObject
-
get
public Object get(String key)
- Specified by:
get
in interfaceBSONObject
-
containsField
public boolean containsField(String s)
- Specified by:
containsField
in interfaceBSONObject
-
keySet
public Set<String> keySet()
- Specified by:
keySet
in interfaceBSONObject
-
isPartialObject
public boolean isPartialObject()
- Specified by:
isPartialObject
in interfaceDBObject
-
markAsPartialObject
public void markAsPartialObject()
- Specified by:
markAsPartialObject
in interfaceDBObject
-
setGridFS
protected void setGridFS(GridFS fs)
Sets the GridFS associated with this file.- Parameters:
fs
- gridFS instance
-
getGridFS
protected GridFS getGridFS()
Gets the GridFS associated with this file- Returns:
- gridFS instance
-
putAll
public void putAll(BSONObject o)
- Specified by:
putAll
in interfaceBSONObject
-
putAll
public void putAll(Map m)
- Specified by:
putAll
in interfaceBSONObject
-
toMap
public Map<?,?> toMap()
- Specified by:
toMap
in interfaceBSONObject
-
removeField
public Object removeField(String key)
- Specified by:
removeField
in interfaceBSONObject
-
-