如何从MultipartFormData获取DataPart?我找不到任何 API 来实现这一点。
Http.MultipartFormData formData = body.asMultipartFormData();
// simple form field
// there is NO getData() or something available
DataPart imageIdPart = formData.getData("dataKey");
// uploaded file
FilePart imagePart = formData.getFile("imageKey");
我不习惯在 Play 2.0 中使用 Java,但是类似的东西可以工作吗?
@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());
}
我是一名优秀的程序员,十分优秀!