-
Feature Request
-
Resolution: Done
-
Minor
-
3.0.17.Final
-
None
I have been trying to read the Content-Type for an InputStream field belonging to a @MultipartForm parameter. This particular parameter also needs to integrate with Hibernate Validator:
@Consumes("multipart/form-data")
@POST
Response myApi(
@Valid
@NotNull
@MultipartForm
MyRequest request
);
where
public class MyRequest { @FormParam("header") @NotNull(message = "{ etc etc }") @Valid private MyHeader header; @FormParam("stuff") @NotNull(message = "{ etc etc }") private InputStream stuff; }
However, any attempt to access the InputPart associated with form parameter "stuff" closes the InputStream. So I suggest updating MultipartFormAnnotationReader so that it supports InputPart as well as InputStream, e.g.
public class MyRequest { @FormParam("header") @NotNull(message = "{ etc etc }") @Valid private MyHeader header; @FormParam("stuff") @NotNull(message = "{ etc etc }") private InputPart stuff; }
I can then retrieve the InputStream using getBody(InputStream.class, null) and also get the field's associated Content-Type header "for free" .
- links to