I am creating a restful web service that processes multiple files from users. from google it seems that the correct mime type should be multipart/mixed so my java web service code (based on Jersey) is something like:
@POST
@Consumes(MultiPartMediaTypes.MULTIPART_MIXED)
@Produces({
MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON
})
@Path("/{Id}")
public CourseBean updateCourse(@PathParam("Id") final String id, final MultiPart multipart)
throws WebServiceException
{
//operations on multipart
String this.id = id;
return null;
}
in the browser, I run below html to try to upload files to the web service:
<h1></h1>
<p>files</p>
<FORM action="http://localhost:8080/rest/1"
enctype="multipart/mixed"
method="POST">
<p>
name:<INPUT type="text" name="submit-name"><BR>
file <INPUT type="file" name="file"><BR>
attachment <INPUT type="file" name="attachment"><BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">
</FORM>
</body>
</html>
please note that the enctype here is "multipart/mixed". however after I select files and click the send button, the mime type of the http request my web service gets is changed to application/x-www-form-urlencoded, and this causes a "Unsupported Media Type" error in the web service side.
but if I change the enctype in the html to multipart/form-data, the mime type of the received request is the same: multipart/form-data.
so my question is, how can I create a html form that can send a http message with mime type "multipart/mixed"? with this html, I can test my web service.
thank you very much.