users@jersey.java.net

Re: [Jersey] multipart/form-data versus multipart/mixed

From: Gili <cowwoc_at_bbs.darktech.org>
Date: Thu, 20 Nov 2008 14:31:41 -0800 (PST)

    Thanks for the detailed answer. I'll try using multipart/mixed instead.

Gili

Craig McClanahan (via Nabble) wrote:
> Gili wrote:
>
> > Hi,
> >
> > Can someone please explain the difference between these two mime
> types? I
> > see Jersey-multipart defaults to multipart/mixed but it isn't clear
> to me
> > what this provides over multipart/form-data which is more common in
> the HTML
> > world (and probably has better support).
> >
> > Thanks,
> > Gili
> >
> The "multipart/form-data" media type was originally introduced in RFC
> 1867 for "Form-based File Upload in HTML". The details of the semantics
> were very specific to that use case ... for example, the use of "name"
> parameters on the Content-Disposition header of each body part, to map
> to the corresponding HTML input field.
>
> The "multipart/mixed" (and other similar types) media type was
> explicitly designed to formalize the transport of related collections of
> body entities in the same message ... the classic use case being email
> attachments. These media types were explicitly designed to be more
> general, so they do not impose any use-case-specific restrictions on
> things like requiring certain headers with certain parameters. The
> definitions are in RFC 2046 through 2049.
>
> Although jersey-multipart will do just fine sending or receiving
> "multipart/form-data" messages, the restrictions on
> "multipart/form-data" semantics make it an unsuitable default media type
> for a newly created MultiPart instance that is intended for general
> purpose use.
>
> If you want to use multipart/form-data, simply change your create
> statement from:
>
> MultiPart multiPart = new MultiPart();
>
> to
>
> MultiPart multiPart = new
> MultiPart(MediaType.MULTIPART_FORM_DATA_TYPE);
>
> or even
>
> MultiPart multiPart = new
> MultiPart().type(MediaType.MULTIPART_FORM_DATA_TYPE);
>
>
> or, create yourself a simple subclass that sets the default
> characteristics you want:
>
> public class MultiPartFormData extends MultiPart {
> public MultiPartFormData() {
> super(MediaType.MULTIPART_FORM_DATA_TYPE);
> }
> }
>
> and use that class instead.
>
> Craig
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=1559302&i=0>
> For additional commands, e-mail: users-help@...
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=1559302&i=1>
>
>
>
> ------------------------------------------------------------------------
> This email is a reply to your post @
> http://n2.nabble.com/multipart-form-data-versus-multipart-mixed-tp1559082p1559302.html
> You can reply by email or by visting the link above.
>

-- 
View this message in context: http://n2.nabble.com/multipart-form-data-versus-multipart-mixed-tp1559082p1559306.html
Sent from the Jersey mailing list archive at Nabble.com.