/** * Creates {@link MultipartBody} from the provided parts. * * @return The {@link MultipartBody} * @throws MultipartException If there are no parts */ public MultipartBody build() throws MultipartException { if (parts.isEmpty()) { throw new MultipartException("Cannot create a MultipartBody with no parts"); } return new MultipartBody(parts); } }
private HttpPostRequestEncoder buildMultipartRequest(NettyClientHttpRequest clientHttpRequest, Object bodyValue) throws HttpPostRequestEncoder.ErrorDataEncoderException { HttpDataFactory factory = new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE); io.netty.handler.codec.http.HttpRequest request = clientHttpRequest.getFullRequest(null); HttpPostRequestEncoder postRequestEncoder = new HttpPostRequestEncoder(factory, request, true, CharsetUtil.UTF_8, HttpPostRequestEncoder.EncoderMode.HTML5); if (bodyValue instanceof MultipartBody.Builder) { bodyValue = ((MultipartBody.Builder) bodyValue).build(); } if (bodyValue instanceof MultipartBody) { postRequestEncoder.setBodyHttpDatas(((MultipartBody) bodyValue).getData(request, factory)); } else { throw new MultipartException(String.format("The type %s is not a supported type for a multipart request body", bodyValue.getClass().getName())); } return postRequestEncoder; }
/** * Creates {@link MultipartBody} from the provided parts. * * @return The {@link MultipartBody} * @throws MultipartException If there are no parts */ public MultipartBody build() throws MultipartException { if (parts.isEmpty()) { throw new MultipartException("Cannot create a MultipartBody with no parts"); } return new MultipartBody(parts); } }
private HttpPostRequestEncoder buildMultipartRequest(NettyClientHttpRequest clientHttpRequest, Object bodyValue) throws HttpPostRequestEncoder.ErrorDataEncoderException { HttpDataFactory factory = new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE); io.netty.handler.codec.http.HttpRequest request = clientHttpRequest.getFullRequest(null); HttpPostRequestEncoder postRequestEncoder = new HttpPostRequestEncoder(factory, request, true, CharsetUtil.UTF_8, HttpPostRequestEncoder.EncoderMode.HTML5); if (bodyValue instanceof MultipartBody.Builder) { bodyValue = ((MultipartBody.Builder) bodyValue).build(); } if (bodyValue instanceof MultipartBody) { postRequestEncoder.setBodyHttpDatas(((MultipartBody) bodyValue).getData(request, factory)); } else { throw new MultipartException(String.format("The type %s is not a supported type for a multipart request body", bodyValue.getClass().getName())); } return postRequestEncoder; }
/** * Creates {@link MultipartBody} from the provided parts. * * @return The {@link MultipartBody} * @throws MultipartException If there are no parts */ public MultipartBody build() throws MultipartException { if (parts.isEmpty()) { throw new MultipartException("Cannot create a MultipartBody with no parts"); } return new MultipartBody(parts); } }
private HttpPostRequestEncoder buildMultipartRequest(NettyClientHttpRequest clientHttpRequest, Object bodyValue) throws HttpPostRequestEncoder.ErrorDataEncoderException { HttpDataFactory factory = new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE); io.netty.handler.codec.http.HttpRequest request = clientHttpRequest.getFullRequest(null); HttpPostRequestEncoder postRequestEncoder = new HttpPostRequestEncoder(factory, request, true, CharsetUtil.UTF_8, HttpPostRequestEncoder.EncoderMode.HTML5); if (bodyValue instanceof MultipartBody.Builder) { bodyValue = ((MultipartBody.Builder) bodyValue).build(); } if (bodyValue instanceof MultipartBody) { postRequestEncoder.setBodyHttpDatas(((MultipartBody) bodyValue).getData(request, factory)); } else { throw new MultipartException(String.format("The type %s is not a supported type for a multipart request body", bodyValue.getClass().getName())); } return postRequestEncoder; }