code: protected int calculateBufferSize(long maxChunkSize) {
          final int KB = 1000;
  
          // Ensure maxChunkSize falls on 1-KB boundaries.
          if (maxChunkSize % KB != 0) {
              String m = "MaxChunkSize must be multiple of " + KB + ": " + maxChunkSize;
              log.error(m);
              throw new DuraCloudRuntimeException(m);
          }
  
          // Find maximum block factor less than or equal to 8-KB.
          long size = maxChunkSize;
          for (int i = 1; i <= maxChunkSize; i++) {
              // MaxChunkSize must be divisible by buffer size
              if ((maxChunkSize % i == 0) && ((maxChunkSize / i) <= (8 * KB))) {
                  size = maxChunkSize / i;
                  break;
              }
          }
  
          log.debug("Buf size: " + size + " for maxChunkSize: " + maxChunkSize);
          return (int) size;
      }
docs: 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.
  
  @param maxChunkSize of chunk stream
  @return efficient buffer size for given arg chunk-size