gpt4 book ai didi

playframework-2.0 - 玩法2 如何从MultipartFormData获取DataPart

转载 作者:太空宇宙 更新时间:2023-11-04 11:34:11 25 4
gpt4 key购买 nike

如何从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());
}

关于playframework-2.0 - 玩法2 如何从MultipartFormData获取DataPart,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43464834/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com