users@jersey.java.net

Re: [Jersey] Jersey handler signature for binary payload ingestion

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 05 May 2009 22:04:20 +0200

On May 5, 2009, at 9:15 PM, Marc Hadley wrote:

> On May 5, 2009, at 2:45 PM, Mark Petrovic wrote:
>
>> I'm curious as to whether anyone has used the Jersey server API to
>> consume a binary payload via HTTP POST. I'm not sure how to
>> express this, or whether Jersey will even allow it, but it seems
>> the handler signature would look something like:
>>
>> @Path("somepath")
>> @POST
>> @Consumes("octet/stream")
>> public void post(byte[] buffer) {
>
> You can use InputStream as the type of the method argument instead:
>
> public void post(InputStream stream) {
>
>> Is this good Jersey form for consuming binary payloads?
>>
> Yes.
>

See the following for more details:

https://jersey.dev.java.net/documentation/1.1.0-ea/user-
guide.html#d4e221

Paul.