Class GridFSFile

java.lang.Object
com.mongodb.client.gridfs.model.GridFSFile

public final class GridFSFile extends Object
The GridFSFile
Since:
3.1
  • Constructor Details

    • GridFSFile

      public GridFSFile(BsonValue id, String filename, long length, int chunkSize, Date uploadDate, @Nullable Document metadata)
      Creates a new GridFSFile
      Parameters:
      id - the id of the file
      filename - the filename
      length - the length, in bytes of the file
      chunkSize - the chunkSize, in bytes of the file
      uploadDate - the upload date of the file
      metadata - the optional metadata for the file
  • Method Details

    • getObjectId

      public ObjectId getObjectId()
      The ObjectId for this file.

      Throws a MongoGridFSException if the file id is not an ObjectId.

      Returns:
      the id for this file.
    • getId

      public BsonValue getId()
      The BsonValue id for this file.
      Returns:
      the id for this file
    • getFilename

      public String getFilename()
      The filename
      Returns:
      the filename
    • getLength

      public long getLength()
      The length, in bytes of this file
      Returns:
      the length, in bytes of this file
    • getChunkSize

      public int getChunkSize()
      The size, in bytes, of each data chunk of this file
      Returns:
      the size, in bytes, of each data chunk of this file
    • getUploadDate

      public Date getUploadDate()
      The date and time this file was added to GridFS
      Returns:
      the date and time this file was added to GridFS
    • getMetadata

      @Nullable public Document getMetadata()
      Any additional metadata stored along with the file
      Returns:
      the metadata document or null
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object