Class GridFSDownloadStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public abstract class GridFSDownloadStream
    extends InputStream
    A GridFS InputStream for downloading data from GridFS

    Provides the GridFSFile for the file to being downloaded as well as the read methods of a InputStream

    This implementation of a InputStream will not throw IOExceptions. However, it will throw a MongoException if there is an error reading from MongoDB.

    • Constructor Detail

      • GridFSDownloadStream

        public GridFSDownloadStream()
    • Method Detail

      • getGridFSFile

        public abstract GridFSFile getGridFSFile()
        Gets the corresponding GridFSFile for the file being downloaded
        the corresponding GridFSFile for the file being downloaded
      • batchSize

        public abstract GridFSDownloadStream batchSize​(int batchSize)
        Sets the number of chunks to return per batch.

        Can be used to control the memory consumption of this InputStream. The smaller the batchSize the lower the memory consumption and higher latency.

        batchSize - the batch size
        MongoDB documentation
        Batch Size
      • read

        public abstract int read()
        Specified by:
        read in class InputStream
      • read

        public abstract int read​(byte[] b)
        read in class InputStream
      • read

        public abstract int read​(byte[] b,
                                 int off,
                                 int len)
        read in class InputStream
      • skip

        public abstract long skip​(long n)
        skip in class InputStream
      • mark

        public abstract void mark()
        Marks the current position in this input stream.

        A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.