application/octet-stream? Can't I say "*"? Someone might send text/html.

On Thu, Jan 26, 2012 at 4:26 PM, Sergey Beryozkin <[email protected]> wrote:
> On 26/01/12 21:07, Benson Margulies wrote:
>>
>> So, say that sometimes something posts multipart/form-data, and other
>> time it posts some other thing.{
>>
>> Do I need two JAX-RS service functions, or if I declare Consumes("*")
>> and have a MultipartBody param (and an InputStream param?) will CXF
>> just null or not null the right one?
>
>
> One option is indeed to have two methods, one with
>
> @Consumes({"multipart/form-data"}),
>
> and another one with say
>
> @Consumes({"application/octet-stream"})
>
> The other option is to get them combined:
>
>
> @Context
> private MessageContext mc;
>
> @Consumes({"multipart/form-data", "application/octet-stream"})
> public void upload(InputStream is) {
>
>   MediaType contentType = mc.getHttpHeaders().getMediaType();
>   if (contentType.equals("multipart/form-data")) {
>       MultipartBody body = AttachmentUtils.getMultipartBody(mc);
>       ...
>   } else {
>       // read the is
>   }
>
>
> }
>
>
> HTH
> Sergey

Reply via email to