Class GridFSDBFile

  • All Implemented Interfaces:
    DBObject, BSONObject

    public class GridFSDBFile
    extends GridFSFile
    This class enables retrieving a GridFS file metadata and content. Operations include:
    • Writing data to a file on disk or an OutputStream
    • Creating an InputStream to stream the data into
    MongoDB documentation
    GridFS
    • Constructor Detail

      • GridFSDBFile

        public GridFSDBFile()
    • Method Detail

      • getInputStream

        public InputStream getInputStream()
        Returns an InputStream from which data can be read.
        Returns:
        the input stream
      • writeTo

        public long writeTo​(String filename)
                     throws IOException
        Writes the file's data to a file on disk.
        Parameters:
        filename - the file name on disk
        Returns:
        number of bytes written
        Throws:
        IOException - if there are problems writing to the file
      • writeTo

        public long writeTo​(File file)
                     throws IOException
        Writes the file's data to a file on disk.
        Parameters:
        file - the File object
        Returns:
        number of bytes written
        Throws:
        IOException - if there are problems writing to the file
      • writeTo

        public long writeTo​(OutputStream out)
                     throws IOException
        Writes the file's data to an OutputStream.
        Parameters:
        out - the OutputStream
        Returns:
        number of bytes written
        Throws:
        IOException - if there are problems writing to out