Class GridFSFile

  • All Implemented Interfaces:
    com.mongodb.DBObject, org.bson.BSONObject
    Direct Known Subclasses:
    GridFSDBFile, GridFSInputFile


    public abstract class GridFSFile
    extends java.lang.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
      boolean containsField​(java.lang.String s)  
      boolean containsKey​(java.lang.String key)
      Deprecated. 
      java.lang.Object get​(java.lang.String key)  
      java.util.List<java.lang.String> getAliases​()
      Gets the aliases from the metadata.
      long getChunkSize​()
      Gets the size of a chunk.
      java.lang.String getContentType​()
      Gets the content type.
      java.lang.String getFilename​()
      Gets the filename.
      protected GridFS getGridFS​()
      Gets the GridFS associated with this file
      java.lang.Object getId​()
      Gets the id.
      long getLength​()
      Gets the file's length.
      java.lang.String getMD5​()
      Deprecated. 
      there is no replacement for this method
      com.mongodb.DBObject getMetaData​()
      Gets the file metadata.
      java.util.Date getUploadDate​()
      Gets the upload date.
      boolean isPartialObject​()  
      java.util.Set<java.lang.String> keySet​()  
      void markAsPartialObject​()  
      int numChunks​()
      Returns the number of chunks that store the file data.
      java.lang.Object put​(java.lang.String key, java.lang.Object v)  
      void putAll​(java.util.Map m)  
      void putAll​(org.bson.BSONObject o)  
      java.lang.Object removeField​(java.lang.String key)  
      void save​()
      Saves the file entry to the files collection
      protected void setGridFS​(GridFS fs)
      Sets the GridFS associated with this file.
      void setMetaData​(com.mongodb.DBObject metadata)
      Gets the file metadata.
      java.util.Map<?,?> toMap​()  
      java.lang.String toString​()  
      void validate​()
      Deprecated. 
      there is no replacement for this method
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • GridFSFile

        public GridFSFile​()
    • 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 method
        Verifies 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 java.lang.Object getId​()
        Gets the id.
        Returns:
        the id of the file.
      • getFilename

        public java.lang.String getFilename​()
        Gets the filename.
        Returns:
        the name of the file
      • getContentType

        public java.lang.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 java.util.Date getUploadDate​()
        Gets the upload date.
        Returns:
        the date
      • getAliases

        public java.util.List<java.lang.String> getAliases​()
        Gets the aliases from the metadata. note: to set aliases, call put(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 java.lang.String getMD5​()
        Deprecated. there is no replacement for this method
        Gets the observed MD5 during transfer
        Returns:
        md5
      • put

        public java.lang.Object put​(java.lang.String key,
                                    java.lang.Object v)
        Specified by:
        put in interface org.bson.BSONObject
      • get

        public java.lang.Object get​(java.lang.String key)
        Specified by:
        get in interface org.bson.BSONObject
      • containsKey

        @Deprecated
        public boolean containsKey​(java.lang.String key)
        Deprecated. 
        Specified by:
        containsKey in interface org.bson.BSONObject
      • containsField

        public boolean containsField​(java.lang.String s)
        Specified by:
        containsField in interface org.bson.BSONObject
      • keySet

        public java.util.Set<java.lang.String> keySet​()
        Specified by:
        keySet in interface org.bson.BSONObject
      • isPartialObject

        public boolean isPartialObject​()
        Specified by:
        isPartialObject in interface com.mongodb.DBObject
      • markAsPartialObject

        public void markAsPartialObject​()
        Specified by:
        markAsPartialObject in interface com.mongodb.DBObject
      • toString

        public java.lang.String toString​()
        Overrides:
        toString in class java.lang.Object
      • 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:
        putAll in interface org.bson.BSONObject
      • putAll

        public void putAll​(java.util.Map m)
        Specified by:
        putAll in interface org.bson.BSONObject
      • toMap

        public java.util.Map<?,?> toMap​()
        Specified by:
        toMap in interface org.bson.BSONObject
      • removeField

        public java.lang.Object removeField​(java.lang.String key)
        Specified by:
        removeField in interface org.bson.BSONObject