@ DoesServiceRequest private synchronized void writeInternal ( final byte [ ] data , int offset , int length ) throws IOException { while ( length > 0 ) { this . checkStreamState ( ) ; final int availableBufferBytes = this . internalWriteThreshold - this . currentBufferedBytes ; final int nextWrite = Math . min ( availableBufferBytes , length ) ; // If we need to set MD5 then update the digest accordingly if ( this . options . getStoreFileContentMD5 ( ) ) { this . md5Digest . update ( data , offset , nextWrite ) ; } this . outBuffer . write ( data , offset , nextWrite ) ; this . currentBufferedBytes += nextWrite ; offset += nextWrite ; length -= nextWrite ; if ( this . currentBufferedBytes == this . internalWriteThreshold ) { this . dispatchWrite ( this . internalWriteThreshold ) ; } } }
Writes the data to the buffer and triggers writes to the service as needed .