How to get a DataPart from MultipartFormData? I could not find any API to get that.
Http.MultipartFormData formData = body.asMultipartFormData();
// simple form
In scala:
def index = Action(parse.multipartFormData) {
request => {
val dataKey = request.body.dataParts.get("dataKey")
something something...
Ok("Ok!")
}
I'm not used to work with Java in Play 2.0, but is something like that working ?
@BodyParser.Of(BodyParser.MultipartFormData.class)
public static Result index() {
Http.MultipartFormData multipartFormData = request().body().asMultipartFormData();
//ask the multipart to be form url encoded...
//and get the data
String[] data = multipartFormData.asFormUrlEncoded().get("dataKey");
//which should not impact such call
Http.MultipartFormData.FilePart image = multipartFormData.getFile("imageKey");
return ok("Got image: " + image.getFilename());
}