users@jersey.java.net

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

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 05 May 2009 15:15:01 -0400

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.

Marc.