Sending Multipart File as POST parameters with RestTemplate requests
Oakeye, thanks for your response again.
That configuration is already on my application-context.xml.
I have:
Code:
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="${maxUploadSize}"/>
</bean>
Code:
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<constructor-arg ref="httpClientFactory" />
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/>
<bean class="org.springframework.http.converter.FormHttpMessageConverter" />
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>
But i still having no luck with the rest template. I will post an example of what a have in my project as soon as possible.
Btw, what do you think that i missing?
For the message of the exception that i getting:
Code:
Could not write request: no suitable HttpMessageConverter found for request type [org.springframework.web.multipart.commons.CommonsMultipartFile]
I think that i need an special converter. Something like an MultipartConverter...
1 Attachment(s)
Sending Multipart File as POST parameters with RestTemplate requests
Hi Oakeye,
I'm posting an (non working :P) example project with the configuration that i am using for post multifileparts through Rest Template.
It would be nice if you can check what i am missing?
To show the upload form, deploy the application and put this URL: http://localhost:8080/sites/postupload
Thanks again!.
Regards.
Mauro.
Sending Multipart File as POST parameters with RestTemplate requests
Hi guys,
Well i think that were are talking about different thinks. It's easy and straightforward make an upload from a JSP page to a Spring Controller.-
But what i trying to do is send Multipart files to a Rest Service using Rest Template.
I mean the workflow, will be:
1- Select the file on JSP and Submit.
2- Spring Controller (App1) receives the File and make a Post For Object to a Rest Service with that file as parameter.
3- Spring Controller - Rest Service (App2) receives the file through @RequestParam.
4- The App2 controller saves the file on the filesystem.
I was investigating an i think that its not an easy task to do due to Spring does not ship a converter for MultipartFiles.
We have to write our own converter for this porpouse.
BTW, Thank for your responses.
M.