public abstract class

GridFSFile

extends Object
implements DBObject
java.lang.Object
   ↳ com.mongodb.gridfs.GridFSFile
Known Direct Subclasses

Class Overview

The abstract class representing a GridFS file

Summary

Fields
protected GridFS _fs
Public Constructors
GridFSFile()
Public Methods
boolean containsField(String s)
Checks if this object contains a field with the given name.
boolean containsKey(String s)
Deprecated
Object get(String key)
Gets a field from this object by a given name.
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
Object getId()
Gets the id
long getLength()
Gets the file's length
String getMD5()
Gets the observed MD5 during transfer
DBObject getMetaData()
Gets the file metadata
Date getUploadDate()
Gets the upload date
boolean isPartialObject()
whether markAsPartialObject was ever called only matters if you are going to upsert and do not want to risk losing fields
Set<String> keySet()
Returns this object's fields' names
void markAsPartialObject()
if this object was retrieved with only some fields (using a field filter) this method will be called to mark it as such.
int numChunks()
Returns the number of chunks that store the file data
Object put(String key, Object v)
Sets a name/value pair in this object.
void putAll(Map m)
Sets all key/value pairs from a map into this object
void putAll(BSONObject o)
Sets all key/value pairs from an object into this object
Object removeField(String key)
Removes a field with a given name from this object.
void save()
Saves the file entry to the files collection
void setMetaData(DBObject metadata)
Gets the file metadata
Map toMap()
Returns a map representing this BSONObject.
String toString()
void validate()
Verifies that the MD5 matches between the database and the local file.
Protected Methods
void setGridFS(GridFS fs)
Sets the GridFS associated with this file
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.mongodb.DBObject
From interface org.bson.BSONObject

Fields

protected GridFS _fs

Public Constructors

public GridFSFile ()

Public Methods

public boolean containsField (String s)

Checks if this object contains a field with the given name.

Parameters
s Field name for which to check
Returns
  • True if the field is present

public boolean containsKey (String s)

Deprecated

Returns
  • True if the key is present

public Object get (String key)

Gets a field from this object by a given name.

Parameters
key The name of the field fetch
Returns
  • The field, if found

public List<String> getAliases ()

Gets the aliases from the metadata. note: to set aliases, call put( "aliases" , List )

public long getChunkSize ()

Gets the size of a chunk

public String getContentType ()

Gets the content type

public String getFilename ()

Gets the filename

public Object getId ()

Gets the id

public long getLength ()

Gets the file's length

public String getMD5 ()

Gets the observed MD5 during transfer

public DBObject getMetaData ()

Gets the file metadata

public Date getUploadDate ()

Gets the upload date

public boolean isPartialObject ()

whether markAsPartialObject was ever called only matters if you are going to upsert and do not want to risk losing fields

public Set<String> keySet ()

Returns this object's fields' names

Returns
  • The names of the fields in this object

public void markAsPartialObject ()

if this object was retrieved with only some fields (using a field filter) this method will be called to mark it as such.

public int numChunks ()

Returns the number of chunks that store the file data

public Object put (String key, Object v)

Sets a name/value pair in this object.

Parameters
key Name to set
v Corresponding value
Returns
  • v

public void putAll (Map m)

Sets all key/value pairs from a map into this object

Parameters
m the map

public void putAll (BSONObject o)

Sets all key/value pairs from an object into this object

Parameters
o the object

public Object removeField (String key)

Removes a field with a given name from this object.

Parameters
key The name of the field to remove
Returns
  • The value removed from this object

public void save ()

Saves the file entry to the files collection

public void setMetaData (DBObject metadata)

Gets the file metadata

public Map toMap ()

Returns a map representing this BSONObject.

Returns
  • the map

public String toString ()

public void validate ()

Verifies that the MD5 matches between the database and the local file. This should be called after transferring a file.

Protected Methods

protected void setGridFS (GridFS fs)

Sets the GridFS associated with this file