Sending multipart HTTP requests using Spring's RestTemplate
Most of the time, we have implemented file upload functionality in our application. Files are sent over HTTP as a multipart request.
In this section, let us see how we can configure the inbound channel adapter using RestTemplate
to send a file over HTTP request.
Let us configure the server with the inbound channel adapter and then write a client for it:
<int-http:inbound-channel-adapter id="httpInboundAdapter" channel="receiveChannel" name="/inboundAdapter.htm" supported-methods="GET, POST"/> <int:channel id="receiveChannel"/> <int:service-activator input-channel="receiveChannel"> <bean class="org.springframework.integration.samples.multipart.MultipartReceiver"/> </int:service-activator> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
The httpInboundAdapter
will receive the request and convert it to a message with a payload LinkedMultiValueMap...