code: public static void multipart(final ChainedHttpConfig config, final ToServer ts) {
          try {
              final ChainedHttpConfig.ChainedRequest request = config.getChainedRequest();
  
              final Object body = request.actualBody();
              if (!(body instanceof MultipartContent)) {
                  throw new IllegalArgumentException("Multipart body content must be MultipartContent.");
              }
  
              final String contentType = request.actualContentType();
              if (!(contentType.equals(MULTIPART_FORMDATA.getAt(0)) || contentType.equals(MULTIPART_MIXED.getAt(0)))) {
                  throw new IllegalArgumentException("Multipart body content must be multipart/form-data.");
              }
  
              final String boundary = randomString(10);
              MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create().setBoundary(boundary);
  
              final String boundaryContentType = "multipart/form-data; boundary=" + boundary;
  
              entityBuilder.setContentType(ContentType.parse(boundaryContentType));
  
              for (final MultipartContent.MultipartPart mpe : ((MultipartContent) body).parts()) {
                  if (mpe.getFileName() == null) {
                      entityBuilder.addTextBody(mpe.getFieldName(), (String) mpe.getContent());
  
                  } else {
                      final byte[] encodedBytes = EmbeddedEncoder.encode(config, mpe.getContentType(), mpe.getContent());
                      entityBuilder.addBinaryBody(mpe.getFieldName(), encodedBytes, parse(mpe.getContentType()), mpe.getFileName());
                  }
              }
  
              request.setContentType(boundaryContentType);
  
              ts.toServer(entityBuilder.build().getContent());
  
          } catch (IOException ioe) {
              ioe.printStackTrace();
          }
      }
docs: Encodes multipart/form-data where the body content must be an instance of the {@link MultipartContent} class. Individual parts will be
  encoded using the encoders available to the {@link ChainedHttpConfig} object.
  
  @param config the chained configuration object
  @param ts the server adapter