Judging by the annotations and your usual questions, it's about JAX-RS.
Use the @Produces
for the byte stream in @Produces
and MediaType.APPLICATION_OCTET_STREAM
.
To receive from a client in a method, use an InputStream
parameter.
@POST @Consumes(MediaType.APPLICATION_OCTET_STREAM) public Response getData(InputStream inputStream) { // вычитывайте данные из inputStream return Response.ok().build(); }
To return to the client bytes:
Give the entire byte array if the data is available in advance and fit into memory:
@GET @Produces(MediaType.APPLICATION_OCTET_STREAM) public Response getData() { byte[] data = ... ; return Response.ok(data).build(); }
either use StreamingOutput
@GET @Produces(MediaType.APPLICATION_OCTET_STREAM) public StreamingOutput getData() { return new StreamingOutput() { public void write(final OutputStream outputStream) { // здесь пишите ваши данные в поток outputStream } }; }
@Produces
,@Consumes
can it be from the world ofPHP
? In other words, formulate your task more precisely - sys_dev