I am trying to implement File Upload using Jersey module in Mule.
My mule flow looks like this:
<flow name="rest-service">
<inbound-endpoint address="http://localhost:9999/testupload"/>
<jersey:resources>
<component class="com.example.test.UploadFileResource"/>
</jersey:resources>
</flow>
If I don't put @Consumes annotation in the resource method in UploadFileResource like below, the method gets called when an HTTP Post request is made using multipart/form-data Content-type and I get HTTP 2xx status code:
@Path("/uploadfile")
public class UploadFileResource {
@POST
public Response uploadFile2(...) {
logger.info("Multipart Upload");
...
}
}
But when I put @Consumes annotation with MULTIPART_FORM_DATA Media Type like below, the method does not get called and I get HTTP 415 Unsupported Media type, even when the HTTP Post request is made using multipart/form-data Content-type:
@Path("/uploadfile")
public class UploadFileResource {
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile2(...) {
logger.info("Multipart Upload");
...
}
}
Any idea why 415 status comes even when @Consumes Media type matches the HTTP Post Content-type header?
#upload2()
method look like? – Michal GajdosuploadFile2()
, and one with two input arguments, i.e.uploadFile2(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail)
. I am getting the same result in both the cases. – Pranav Pal