Hi Hendy,
their is a MessageBodyReader for Multipart. Use it as follows:
@POST
@Path("{id}")
@Produces("text/plain")
public String postDatabase(Multipart multipart, @PathParam("id") String
id) {
In this moment I can't say, if this MessageBodyReader is ready
implemented. Test it and let me now!
@Context does not support the HttpServletRequest for now, because the
HttpServletRequest is not the base of Restlet. It could come later.
best regards
Stephan
Hendy Irawan schrieb:
> How do I upload a file (multipart form data) to a JAX-RS Restlet resource?
>
> I tried using @Context HttpServletRequest and planning to use Apache
> Commons FileUpload on that. However, simply specifying @Context
> HttpServletRequest gives me:
>
>
> HTTP ERROR: 405
>
> The method specified in the request is not allowed for the resource
> identified by the request URI
>
> RequestURI=/x
>
> My signature is:
>
> @POST
> @Path("{id}")
> @Produces("text/plain")
> public String postDatabase(@Context HttpServletRequest request,
> @PathParam("id") String id) {
>
> However, removing the @Context gives me no errors
>
> @POST
> @Path("{id}")
> @Produces("text/plain")
> public String postDatabase(@PathParam("id") String id) {
>
> But in this case I won't be able to do anything with the request/file
> upload.
>
> Any help / workarounds is highly appreciated.
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1258228