users@jersey.java.net

Re: [Jersey] Working with binary files (images/files, etc) via REST

From: Charles Overbeck <coverbec_at_pacbell.net>
Date: Wed, 15 Sep 2010 10:01:31 -0700 (PDT)

Hi Paul,


Thanks for the feedback, I'll give it a try.

>>Try the following instead:

  @POST
  @Consumes("application/octet-stream")
  public void upload(InputStream stream, @HeaderParam("Content-Disposition ")
ContentDisposition cd) {
     String name = cd.getFileName();
     // Read from stream and save bytes with name in database.
  }
<<

Sheesh, that makes it too easy! I don't know how I overlooked @HeaderParam. I'll
have to go through my code to see if there are other places where I've made my
life unnecessarily complicated.

Charles