Hi
Lets start from the service side.
If you expect the service clients posting the recursive parts like the
ones shown in the HTML form example, where a single part with a name
'files' contains a variable number of embedded parts, then having a
Multipart(name="files") List<Attachment>
or
Multipart(name="files") List<MyType>
in the method signature is required. That is the only way to get to the
content of the given 'files' part which contains the embedded parts, one
per each file, etc.
After a while users started reporting that either their scripts or
browsers were actually not formatting the payloads according to that
HTML form example, and in fact, when they tried to submit multiple
files, the payload was containing many parts with the same name 'files'.
So I updated the code to ensure the above signature supports this case too.
So whichever way the client formats the payload in case where multiple
files/objects are expected the above signature will capture all of them.
If it is Attachment then you do attachment.getObject(MyType.class), or
if you have MyType then CXF will read the part stream itself into MyType.
On the client side, as I already mentioned, we can not yet model an
individual part containing embedded parts, but it should not make a diff
for the service code...You can try both CXF and say Apache Http client
code against the service to confirm
Thanks, Sergey
On 31/05/17 15:34, nicolasduminil wrote:
Hi Sergey,
Many thanks again for these explanations. I think I'm on the point of
getting it. I only would have a last question: if I have to pass an Object
and a list of of FileInputStream to the resource, I would pass it as a list
of attachments, right ? I'd be using the constructor
Attachment(String id, InputStream is, ContentDisposition cd) ;
to build the attachments for the input streams but how can I build the
attchment to my object ? Would it be:
Attachment(String id, String mediaType, Object object)
But then how could I get this object on the service side ? Given that
finally I decided to have only one parameter of type MultipartBody on the
service side ?
What I mean is that there is not any constructor like:
Attachment(String id, String mediaType, Object object, ContentDisposition
cd);
and hence I cannot get the object as usual via:
attachment.getHeaders().getFirst("Content-Disposition");
Many thanks in advance,
Nicolas
--
View this message in context:
http://cxf.547215.n5.nabble.com/HTTP-415-raised-by-JAX-RS-service-consuming-multipart-tp5780784p5780868.html
Sent from the cxf-user mailing list archive at Nabble.com.