How do you catch incoming @Post variables when it is a multipart/form-data request?
For a regular Post request I would do:
@Post
public void postExample(Representation entity) throws Exception{
Form form = new Form(entity);
System.out.println(form.getFirstValue("something"));
}
But because it is a multipart/form-data request the above outputs null
I'm a Java newbie so be gentle :)
PS: I'm not interested in processing the incoming files, just the text fields.
This is a paste from one of my methods (Restlet 2.0). Here I have a form that includes one file upload plus other fields, therefore it is rather complete:
I'll end up refactoring it to something more generic, but this is what I have by now.
To answer my own question, this is not currently feasible in version 1.2
to pack it on one line, in you Restlet Resource class :
Iterator it = new RestletFileUpload(new DiskFileItemFactory()).parseRequest(getRequest()).iterator();
Then in your loop through your items, you can test whether they are or not fileItems with the method: isFormField().
Testing if a fileItem is a formField... makes sens ? ;)
but it works.
Good luck.