Stephan, by the way, I'm not seeing

'MailAttachmentInterceptor' in CXF source...

Cheers, Sergey

On 11/12/12 13:44, Sergey Beryozkin wrote:
Hi Stephan

On 11/12/12 13:17, Klevenz, Stephan wrote:
Dear CXF Gurus and Community!

I want to consume a multipart/mixed payload via a stream like shown in
the example code below. Unfortunately it seems that injected stream is
already closed and can not be used anymore. Debugging CXF shows that a
MailAttachmentInterceptor has taken the stream before it is injected.
Is there an option to avoid that behavior?

Thanks in advance.

Greetings,
Stephan


@POST
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
public StreamingOutput createItem(InputStream requestBodyStream) {
/* read the requestBodyStream like a normal input stream */
return new StreamingOutput() {

public void write(OutputStream output) throws IOException,
WebApplicationException {
byte[] out = /* get some bytes to write */
output.write(out);
}
})
}


Can you replace the above with

public StreamingOutput createItem(MultipartBody body) {

// assuming a single attachment:
InputStream is = body.getRootAttachment().getObject(InputStream.class);
//or

InputStream is = body.getAttachmentObject("partId", InputStream.class);

}

Quite a few other options are also possible, please see

http://cxf.apache.org/docs/jax-rs-multiparts.html

Let me know please if it works for you
HTH, Sergey

Reply via email to