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
public abstract class GridFSFile extends Object implements com.mongodb.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 Deprecated Methods Modifier and Type Method Description booleancontainsField(String s)booleancontainsKey(String key)Deprecated.Objectget(String key)List<String>getAliases()Gets the aliases from the metadata.longgetChunkSize()Gets the size of a chunk.StringgetContentType()Gets the content type.StringgetFilename()Gets the filename.protected GridFSgetGridFS()Gets the GridFS associated with this fileObjectgetId()Gets the id.longgetLength()Gets the file's length.StringgetMD5()Deprecated.there is no replacement for this methodcom.mongodb.DBObjectgetMetaData()Gets the file metadata.DategetUploadDate()Gets the upload date.booleanisPartialObject()Set<String>keySet()voidmarkAsPartialObject()intnumChunks()Returns the number of chunks that store the file data.Objectput(String key, Object v)voidputAll(Map m)voidputAll(org.bson.BSONObject o)ObjectremoveField(String key)voidsave()Saves the file entry to the files collectionprotected voidsetGridFS(GridFS fs)Sets the GridFS associated with this file.voidsetMetaData(com.mongodb.DBObject metadata)Gets the file metadata.Map<?,?>toMap()StringtoString()voidvalidate()Deprecated.there is no replacement for this method
-
-
-
Method Detail
-
save
public void save()
Saves the file entry to the files collection- Throws:
com.mongodb.MongoException- if there's a failure
-
validate
@Deprecated public void validate()
Deprecated. there is no replacement for this methodVerifies that the MD5 matches between the database and the local file. This should be called after transferring a file.- 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
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 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
-
getMD5
@Deprecated public String getMD5()
Deprecated. there is no replacement for this methodGets the observed MD5 during transfer- Returns:
- md5
-
containsKey
@Deprecated public boolean containsKey(String key)
Deprecated.- Specified by:
containsKeyin interfaceorg.bson.BSONObject
-
containsField
public boolean containsField(String s)
- Specified by:
containsFieldin interfaceorg.bson.BSONObject
-
isPartialObject
public boolean isPartialObject()
- Specified by:
isPartialObjectin interfacecom.mongodb.DBObject
-
markAsPartialObject
public void markAsPartialObject()
- Specified by:
markAsPartialObjectin interfacecom.mongodb.DBObject
-
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(org.bson.BSONObject o)
- Specified by:
putAllin interfaceorg.bson.BSONObject
-
putAll
public void putAll(Map m)
- Specified by:
putAllin interfaceorg.bson.BSONObject
-
toMap
public Map<?,?> toMap()
- Specified by:
toMapin interfaceorg.bson.BSONObject
-
-