private int getEncodedSize(byte[] bytes) throws Exception {
    int encodedSize = 0;
    InMemoryFile[] files = {new InMemoryFile(RestUtils.MultipartPost.BLOB_PART, ByteBuffer.wrap(bytes))};
    HttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/");
    HttpPostRequestEncoder encoder = createEncoder(httpRequest, files);
    encoder.finalizeRequest();
    while (!encoder.isEndOfInput()) {
      HttpContent httpContent = encoder.readChunk(PooledByteBufAllocator.DEFAULT);
      encodedSize += httpContent.content().readableBytes();
    }
    return encodedSize;
  }
Gets the encoded size for a set of bytes
@param bytes the bytes to encode.
@return the encoded size
@throws Exception
ambry-rest/src/test/java/com/github/ambry/rest/NettyMultipartRequestTest.java