users@jersey.java.net

Re: [Jersey] sending word doc file as attachment using jersey-multipart [NC]

From: Craig McClanahan <Craig.McClanahan_at_Sun.COM>
Date: Wed, 29 Apr 2009 22:28:41 -0700

Vidhya MAHADEVAN wrote:
> Thankyou Craig and Paul.
> Here is some more data on my problem.
> Simple docs that dont have any complex content (like images etc) work fine.
> Images , exe dont work.
>
> I have tried setting the octet-stream.
> I have used byte[] and stream to the entity for a body part.
> This does not work though.
>
> Does jersey client support all these media content types ?
> http://www.usf.uni-osnabrueck.de/infoservice/wwwfaq/mime.htm
>
> Thanks again,
> Vidhya
>
>
No, Jersey does not have providers for all those media types ... but
that won't matter if you did what I suggested and set the media type on
the body part to "application/octet-stream". This just copies the input
stream byte-for-byte and doesn't perform any translations. The other
thing to review, though, is to answer this question: when an MS Word
document references an image, is the image *itself* stored inside the
word document, or is it just a URL or something pointing at an external
file containing the image? (I don't know, which is why I'm asking.) If
it's the latter, then uploading just the document file is going to
result in exactly what you are seeing, because the image won't exist on
the server unless you upload it too.

The other potential concern is that jersey-multipart might mess up on
binary body parts ... I haven't seen any reported issues about that, but
I don't see that we have it covered in the unit tests either, so I'm
going to be expanding the tests to ensure we've tested this scenario as
well.

Craig