cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: maybe multipart, maybe not
Date Thu, 26 Jan 2012 21:36:23 GMT
Yes, for a combined case you can just say "*/*" or just omit @Consumes

Sergey

On 26/01/12 21:32, Benson Margulies wrote:
> application/octet-stream? Can't I say "*"? Someone might send text/html.
>
> On Thu, Jan 26, 2012 at 4:26 PM, Sergey Beryozkin<sberyozkin@gmail.com>  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

Mime
View raw message