code: private void flushBuffer(boolean close) {
      for (HttpImageUploadChannel ch : uploadChannels) {
        ch.send(buffer);
      }
      if (!close) {
        // allocate new buffer, since the old one is used by the channels for
        // reading
        buffer = new ByteArrayOutputStream((int) (1.2 * flushSize));
      }
    }
docs: Flushes the buffer to the upload channels and allocates a new buffer.