private HttpPostRequestEncoder createEncoder(HttpRequest request, InMemoryFile[] parts)
      throws HttpPostRequestEncoder.ErrorDataEncoderException, IOException {
    HttpDataFactory httpDataFactory = new DefaultHttpDataFactory(false);
    HttpPostRequestEncoder encoder = new HttpPostRequestEncoder(httpDataFactory, request, true);
    if (parts != null) {
      for (InMemoryFile part : parts) {
        FileUpload fileUpload =
            new MemoryFileUpload(part.name, part.name, "application/octet-stream", "", Charset.forName("UTF-8"),
                part.content.remaining());
        fileUpload.setContent(Unpooled.wrappedBuffer(part.content));
        encoder.addBodyHttpData(fileUpload);
      }
    }
    return encoder;
  }
Creates a {@link HttpPostRequestEncoder} that encodes the given {@code request} and {@code parts}.
@param request the {@link HttpRequest} containing headers and other metadata about the request.
@param parts the {@link InMemoryFile}s that will form the parts of the request.
@return a {@link HttpPostRequestEncoder} that can encode the {@code request} and {@code parts}.
@throws HttpPostRequestEncoder.ErrorDataEncoderException
@throws IOException
ambry-rest/src/test/java/com/github/ambry/rest/NettyMultipartRequestTest.java