Class ChunkableContent

    • Constructor Detail

      • ChunkableContent

        public ChunkableContent​(String contentId,
                                InputStream largeStream,
                                long contentSize,
                                long maxChunkSize)
      • ChunkableContent

        public ChunkableContent​(String contentId,
                                String contentMimetype,
                                InputStream largeStream,
                                long contentSize,
                                long maxChunkSize)
    • Method Detail

      • calculateBufferSize

        protected int calculateBufferSize​(long maxChunkSize)
        This method finds the maximum 1-KB divisor of arg maxChunkSize that is less than 8-KB. It also ensures that arg maxChunkSize is a multiple of 1-KB, otherwise the stream buffering would lose bytes if the maxChunkSize was not divisible by the buffer size. Additionally, by making the buffer multiples of 1-KB ensures efficient block-writing.
        Parameters:
        maxChunkSize - of chunk stream
        Returns:
        efficient buffer size for given arg chunk-size
      • hasNext

        public boolean hasNext()
        This method indicates if there are any more chunks.
        Specified by:
        hasNext in interface Iterator<ChunkInputStream>
        Returns:
        true if more chunks are available.
      • next

        public ChunkInputStream next()
        This method returns the next chunk of the wrapped InputStream.

        Throws a runtime exception if next() is called before previous stream was fully read.

        Specified by:
        next in interface Iterator<ChunkInputStream>
        Returns:
        next chunk as InputStream
      • setPreserveChunkMD5s

        public void setPreserveChunkMD5s​(boolean preserveChunkMD5s)
      • getMaxChunkSize

        public long getMaxChunkSize()