@Override
  public long writeTo(WritableByteChannel channel) throws IOException {
    if (bufferToSend == null) {
      prepareBuffer();
    }
    if (nioBuffers == null) {
      nioBuffers = bufferToSend.nioBuffers();
    }
    long written = 0;
    if (sentBytes < sizeInBytes()) {
      int totalWrittenBytes = 0, currentWritten = -1;
      while (bufferIndex < nioBuffers.length && currentWritten != 0) {
        currentWritten = -1;
        ByteBuffer byteBuffer = nioBuffers[bufferIndex];
        if (!byteBuffer.hasRemaining()) {
          // some bytebuffers are zero length, ignore those bytebuffers.
          bufferIndex++;
        } else {
          currentWritten = channel.write(byteBuffer);
          totalWrittenBytes += currentWritten;
        }
      }
      bufferToSend.skipBytes(totalWrittenBytes);
      written += totalWrittenBytes;
    }
    sentBytes += written;
    return written;
  }
Construct the bufferToSend to serialize request metadata and other blob related information. The newly constructed
bufferToSend will not include the blob content as it's carried by the {@code blob} field in this class.
ambry-protocol/src/main/java/com/github/ambry/protocol/PutRequest.java