I don't know whether there is binary support in JSON (Jackson or
Jettison). You may have to use multipart/form-data with one part the
JSON metadata and the other the image.
form params will work, but you will have to do your own json unmarshalling.
FYI, I'm not sure what the best practice is here. I assume its
multipart/form-data as thats what I believe a browser-based app would
use to upload a file + metadata. I guess what I'm saying is follow what
a browser-based app would do (whatever that is exactly I'm not sure).
On 4/3/11 2:31 PM, colin gray wrote:
>
>
> Hello,
>
> I need to build a REST web service that will need to accept the
> following. Any help getting started would be greatly appreciated. I'm
> using RESTEasy 2.1.GA <http://2.1.GA>.
>
> -accepts a JSON POST the contains String data and also an Image. I'm not
> sure what data type the image will be sent as but I'm assuming
> InputStream is what I'll recommend.
>
> Background: web service method will then need to create the image based
> on the InputStream (or alternate data type) and store is on the file
> system. I know what to do here, but I'm unsure what data type to assign
> to the image and if the annotation below is proper. Below was my thoughts
>
> 1:
> 2:
> 3:
> 4:
> 5:
> 6:
> 7:
> 8:
>
>
>
> @PUT
> @POST
> @Path("dream/{dreamId}/delete")
> @Produces({"application/xml","application/json"})
> public APIResponse deleteDream(@PathParam("dreamId") Long id, @FormParam("title") String title. @FormParam("image" InputStream) {
>
>
> }
>
>
> --
> Colin Gray
>
>
>
> ------------------------------------------------------------------------------
> Create and publish websites with WebMatrix
> Use the most popular FREE web apps or write code yourself;
> WebMatrix provides all the features you need to develop and
> publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
>
>
>
> _______________________________________________
> Resteasy-developers mailing list
> Resteasy-developers@...
> https://lists.sourceforge.net/lists/listinfo/resteasy-developers
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
|