users@jersey.java.net

Re: [Jersey] Question: Best practices related to Eclipse project structure

From: Andrew Feller <afelle1_at_lsu.edu>
Date: Thu, 05 Feb 2009 15:09:06 -0600

Craig,

I read one of your earlier posts where you recommended using Java Mail API
for MIME discovery, however I was looking for a way to determine MIME types
from a java.io.File or java.io.InputStream. I am working on a Jersey REST
resource that consumes XML that contains multiple Base64 encoded documents
(PDFs, images, MS Office documents) and transforms them into PDFs. As you
can guess, I need to determine whether a file is a PDF or not. I noticed
the multipart project could do this with MultiPart objects, but didnšt know
if there was a way to do it natively in Sun provided libraries.

I also realized there could be some use for MultiPart utilities that could
easily glean file attachment information such as file name instead of doing
something like:

MultiPart.getBodyParts().get(#).getParameterizedHeaders().get("Content-Dispo
sition").get(0).getParameters().get("filename"));

Thanks and keep up the good work,
Andrew

On 2/5/09 1:37 PM, "Craig McClanahan" <Craig.McClanahan_at_Sun.COM> wrote:

> Andrew Feller wrote:
>> Re: [Jersey] Question: Best practices related to Eclipse project structure
>> Craig,
>>
>> Very neat!
>>
>> Are you still working on the jersey-multipart project?
> I am.
>> If so, have you considered any type of utility classes for working with
>> multipart attachments? Aside from the Java Mail API library, is there any
>> library you recommend for determining MIME types from input streams?
>>
>>
> Well, jersey-multipart already figures out the MIME types of each body part
> for you -- see BodyPart.getMediaType() -- in fact, it uses JavaMail under the
> covers to parse the incoming multipart message bodies. Is there some
> particular functionality that you think is missing?
>> Thanks again Craig,
>> Andrew
>>
>>
> Craig
>
>

-- 
Andrew Feller, Analyst
LSU University Information Services
200 Frey Computing Services Center
Baton Rouge, LA 70803
Office: 225.578.3737
Fax: 225.578.6400