1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.bremersee.apiclient.webflux.contract.spring;
18
19 import org.springframework.core.convert.converter.Converter;
20 import org.springframework.http.HttpEntity;
21 import org.springframework.http.client.MultipartBodyBuilder;
22 import org.springframework.http.codec.multipart.Part;
23
24
25
26
27
28
29 public class PartToHttpEntityConverter implements Converter<Part, HttpEntity<?>> {
30
31 private final MultipartBodyBuilder multipartBodyBuilder = new MultipartBodyBuilder();
32
33 @Override
34 public HttpEntity<?> convert(Part source) {
35 multipartBodyBuilder.part(source.name(), source);
36 return multipartBodyBuilder.build().getFirst(source.name());
37 }
38 }