Nick
Nick

Reputation: 41

Form post through REST Client - Multipart Upload

I'm trying to use REST Client for Firefox as a mock form to post multipart file data to a Spring 3-driven controller and subsequent handlers. I have our Web Services project configured such that we are able to send XML/JSON requests, which are marshaled/unmarshaled and consumed in the usual way. When I try to use the enctype="multipart/form-data" (by sending the Content-Type="multipart/form-data"), I immediately get :

org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found

I've been sure to include this in my rest-servlet configuration :

<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="maxUploadSize" value="100000"/>
</bean>

Thinking that this was a limitation of the commons FileUpload jar version, I tried to older releases, but to no avail. Same with my REST Client, trying both this and this

My ultimate goal would be to have JAXB marshal a specified file into an object that contains a byte[] automatically. For a great reference as to what I'd like to see, this post hits exactly that, but it uses RESTEasy as the implementation, whereas I use Spring 3 (and this cannot be changed).

Ideally, POSTing this XML :

<fileUpload>
    <username>user123</username>
    <localFileToBeUploaded>path/to/file</localFileToBeUploaded>
</fileUpload>

Would result in an FileUpload object containing the username as a String and the file as either a byte array, InputStream, or actual File object, which gets mapped to some specific controller for handling. I'm comfortable with the XML marshaling, but I'm lost as to how to deal with the file aspect.

Is this possible or am I mixing two different paradigms? I haven't been able to come across anything like this, which leads me to believe I'm a little out in left field. Any ideas or comments would be hugely helpful. Thank you!

Upvotes: 4

Views: 12792

Answers (1)

jediwompa
jediwompa

Reputation: 21

This will be available in REST Client 3.1 it looks like: http://code.google.com/p/rest-client/issues/detail?id=100

Upvotes: 2

Related Questions